mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 10:36:54 -07:00
more work
This commit is contained in:
parent
81c492aa14
commit
6054f0d436
15 changed files with 192 additions and 23 deletions
43
RequestPlex.Api/PlexApi.cs
Normal file
43
RequestPlex.Api/PlexApi.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Nancy.Json;
|
||||
|
||||
namespace RequestPlex.Api
|
||||
{
|
||||
public class PlexApi
|
||||
{
|
||||
public void GetToken(string username, string password)
|
||||
{
|
||||
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes("username:password");
|
||||
string auth = System.Convert.ToBase64String(plainTextBytes);
|
||||
|
||||
using (var client = new WebClient())
|
||||
{
|
||||
var values = new NameValueCollection
|
||||
{
|
||||
["Authorization"] = "Basic " + auth,
|
||||
["X-Plex-Client-Identifier"] = "RequestPlex0001",
|
||||
["X-Plex-Product"] = "Request Plex",
|
||||
["X-Plex-Version"] = "0.1.0"
|
||||
};
|
||||
|
||||
client.Headers.Add(values);
|
||||
|
||||
var response = client.UploadString("https://plex.tv/users/sign_in.json", "");
|
||||
|
||||
var json = new JavaScriptSerializer();
|
||||
dynamic result = json.DeserializeObject(response);
|
||||
|
||||
var token = result["user"]["authentication_token"];
|
||||
|
||||
Debug.WriteLine(token);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,6 +30,14 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Dapper, Version=1.40.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Dapper.1.42\lib\net45\Dapper.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Nancy, Version=1.4.2.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Nancy.1.4.3\lib\net40\Nancy.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
|
@ -54,6 +62,7 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="ApiRequest.cs" />
|
||||
<Compile Include="Models\MovieSearch.cs" />
|
||||
<Compile Include="PlexApi.cs" />
|
||||
<Compile Include="TheMovieDbApi.cs" />
|
||||
<Compile Include="MovieBase.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Dapper" version="1.42" targetFramework="net452" />
|
||||
<package id="Nancy" version="1.4.3" targetFramework="net452" />
|
||||
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net452" />
|
||||
<package id="RestSharp" version="105.2.3" targetFramework="net452" />
|
||||
<package id="TMDbLib" version="0.9.0.0-alpha" targetFramework="net452" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue