diff --git a/Ombi/Ombi.Api.Plex/IPlexApi.cs b/Ombi/Ombi.Api.Plex/IPlexApi.cs new file mode 100644 index 000000000..8591bfbd5 --- /dev/null +++ b/Ombi/Ombi.Api.Plex/IPlexApi.cs @@ -0,0 +1,14 @@ +using System.Threading.Tasks; +using Ombi.Api.Plex.Models; +using Ombi.Api.Plex.Models.Server; +using Ombi.Api.Plex.Models.Status; + +namespace Ombi.Api.Plex +{ + public interface IPlexApi + { + Task GetStatus(string authToken, string uri); + Task SignIn(UserRequest user); + Task GetServer(string authToken); + } +} \ No newline at end of file diff --git a/Ombi/Ombi.Api.Plex/Models/PlexAuthentication.cs b/Ombi/Ombi.Api.Plex/Models/PlexAuthentication.cs new file mode 100644 index 000000000..b93064a41 --- /dev/null +++ b/Ombi/Ombi.Api.Plex/Models/PlexAuthentication.cs @@ -0,0 +1,10 @@ +using System; +using System.Text; + +namespace Ombi.Api.Plex.Models +{ + public class PlexAuthentication + { + public User user { get; set; } + } +} diff --git a/Ombi/Ombi.Api.Plex/Models/PlexUserRequest.cs b/Ombi/Ombi.Api.Plex/Models/PlexUserRequest.cs new file mode 100644 index 000000000..572d689e8 --- /dev/null +++ b/Ombi/Ombi.Api.Plex/Models/PlexUserRequest.cs @@ -0,0 +1,33 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2017 Jamie Rees +// File: PlexUserRequest.cs +// Created By: Jamie Rees +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// ************************************************************************/ +#endregion +namespace Ombi.Api.Plex.Models +{ + public class PlexUserRequest + { + public UserRequest user { get; set; } + } +} \ No newline at end of file diff --git a/Ombi/Ombi.Api.Plex/Models/Roles.cs b/Ombi/Ombi.Api.Plex/Models/Roles.cs new file mode 100644 index 000000000..6c80ec5c8 --- /dev/null +++ b/Ombi/Ombi.Api.Plex/Models/Roles.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace Ombi.Api.Plex.Models +{ + public class Roles + { + public List roles { get; set; } + } +} \ No newline at end of file diff --git a/Ombi/Ombi.Api.Plex/Models/Server/PlexServer.cs b/Ombi/Ombi.Api.Plex/Models/Server/PlexServer.cs new file mode 100644 index 000000000..72ae27343 --- /dev/null +++ b/Ombi/Ombi.Api.Plex/Models/Server/PlexServer.cs @@ -0,0 +1,47 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2017 Jamie Rees +// File: PlexServer.cs +// Created By: Jamie Rees +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// ************************************************************************/ +#endregion + +using System.Collections.Generic; +using System.Xml.Serialization; + +namespace Ombi.Api.Plex.Models.Server +{ + [XmlRoot(ElementName = "MediaContainer")] + public class PlexServer + { + [XmlElement(ElementName = "Server")] + public List Server { get; set; } + [XmlAttribute(AttributeName = "friendlyName")] + public string FriendlyName { get; set; } + [XmlAttribute(AttributeName = "identifier")] + public string Identifier { get; set; } + [XmlAttribute(AttributeName = "machineIdentifier")] + public string MachineIdentifier { get; set; } + [XmlAttribute(AttributeName = "size")] + public string Size { get; set; } + } +} \ No newline at end of file diff --git a/Ombi/Ombi.Api.Plex/Models/Server/ServerInfo.cs b/Ombi/Ombi.Api.Plex/Models/Server/ServerInfo.cs new file mode 100644 index 000000000..1e1f6c5e9 --- /dev/null +++ b/Ombi/Ombi.Api.Plex/Models/Server/ServerInfo.cs @@ -0,0 +1,41 @@ +using System.Xml.Serialization; + +namespace Ombi.Api.Plex.Models.Server +{ + [XmlRoot(ElementName = "Server")] + public class ServerInfo + { + [XmlAttribute(AttributeName = "accessToken")] + public string AccessToken { get; set; } + [XmlAttribute(AttributeName = "name")] + public string Name { get; set; } + [XmlAttribute(AttributeName = "address")] + public string Address { get; set; } + [XmlAttribute(AttributeName = "port")] + public string Port { get; set; } + [XmlAttribute(AttributeName = "version")] + public string Version { get; set; } + [XmlAttribute(AttributeName = "scheme")] + public string Scheme { get; set; } + [XmlAttribute(AttributeName = "host")] + public string Host { get; set; } + [XmlAttribute(AttributeName = "localAddresses")] + public string LocalAddresses { get; set; } + [XmlAttribute(AttributeName = "machineIdentifier")] + public string MachineIdentifier { get; set; } + [XmlAttribute(AttributeName = "createdAt")] + public string CreatedAt { get; set; } + [XmlAttribute(AttributeName = "updatedAt")] + public string UpdatedAt { get; set; } + [XmlAttribute(AttributeName = "owned")] + public string Owned { get; set; } + [XmlAttribute(AttributeName = "synced")] + public string Synced { get; set; } + [XmlAttribute(AttributeName = "sourceTitle")] + public string SourceTitle { get; set; } + [XmlAttribute(AttributeName = "ownerId")] + public string OwnerId { get; set; } + [XmlAttribute(AttributeName = "home")] + public string Home { get; set; } + } +} \ No newline at end of file diff --git a/Ombi/Ombi.Api.Plex/Models/Status/Directory.cs b/Ombi/Ombi.Api.Plex/Models/Status/Directory.cs new file mode 100644 index 000000000..6f96c88b7 --- /dev/null +++ b/Ombi/Ombi.Api.Plex/Models/Status/Directory.cs @@ -0,0 +1,9 @@ +namespace Ombi.Api.Plex.Models.Status +{ + public class Directory + { + public int count { get; set; } + public string key { get; set; } + public string title { get; set; } + } +} \ No newline at end of file diff --git a/Ombi/Ombi.Api.Plex/Models/Status/Mediacontainer.cs b/Ombi/Ombi.Api.Plex/Models/Status/Mediacontainer.cs new file mode 100644 index 000000000..d5079ad03 --- /dev/null +++ b/Ombi/Ombi.Api.Plex/Models/Status/Mediacontainer.cs @@ -0,0 +1,51 @@ +namespace Ombi.Api.Plex.Models.Status +{ + public class Mediacontainer + { + public int size { get; set; } + public bool allowCameraUpload { get; set; } + public bool allowChannelAccess { get; set; } + public bool allowMediaDeletion { get; set; } + public bool allowSharing { get; set; } + public bool allowSync { get; set; } + public bool backgroundProcessing { get; set; } + public bool certificate { get; set; } + public bool companionProxy { get; set; } + public string countryCode { get; set; } + public string diagnostics { get; set; } + public bool eventStream { get; set; } + public string friendlyName { get; set; } + public bool hubSearch { get; set; } + public bool itemClusters { get; set; } + public string machineIdentifier { get; set; } + public bool mediaProviders { get; set; } + public bool multiuser { get; set; } + public bool myPlex { get; set; } + public string myPlexMappingState { get; set; } + public string myPlexSigninState { get; set; } + public bool myPlexSubscription { get; set; } + public string myPlexUsername { get; set; } + public bool photoAutoTag { get; set; } + public string platform { get; set; } + public string platformVersion { get; set; } + public bool pluginHost { get; set; } + public bool readOnlyLibraries { get; set; } + public bool requestParametersInCookie { get; set; } + public int streamingBrainVersion { get; set; } + public bool sync { get; set; } + public int transcoderActiveVideoSessions { get; set; } + public bool transcoderAudio { get; set; } + public bool transcoderLyrics { get; set; } + public bool transcoderPhoto { get; set; } + public bool transcoderSubtitles { get; set; } + public bool transcoderVideo { get; set; } + public string transcoderVideoBitrates { get; set; } + public string transcoderVideoQualities { get; set; } + public string transcoderVideoResolutions { get; set; } + public int updatedAt { get; set; } + public bool updater { get; set; } + public string version { get; set; } + public bool voiceSearch { get; set; } + public Directory[] Directory { get; set; } + } +} \ No newline at end of file diff --git a/Ombi/Ombi.Api.Plex/Models/Status/PlexStatus.cs b/Ombi/Ombi.Api.Plex/Models/Status/PlexStatus.cs new file mode 100644 index 000000000..7d30a100e --- /dev/null +++ b/Ombi/Ombi.Api.Plex/Models/Status/PlexStatus.cs @@ -0,0 +1,34 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2017 Jamie Rees +// File: PlexStatus.cs +// Created By: Jamie Rees +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// ************************************************************************/ +#endregion +namespace Ombi.Api.Plex.Models.Status +{ + + public class PlexStatus + { + public Mediacontainer MediaContainer { get; set; } + } +} \ No newline at end of file diff --git a/Ombi/Ombi.Api.Plex/Models/Subscription.cs b/Ombi/Ombi.Api.Plex/Models/Subscription.cs new file mode 100644 index 000000000..90a0cde25 --- /dev/null +++ b/Ombi/Ombi.Api.Plex/Models/Subscription.cs @@ -0,0 +1,10 @@ +namespace Ombi.Api.Plex.Models +{ + public class Subscription + { + public bool active { get; set; } + public string status { get; set; } + public object plan { get; set; } + public object features { get; set; } + } +} \ No newline at end of file diff --git a/Ombi/Ombi.Api.Plex/Models/User.cs b/Ombi/Ombi.Api.Plex/Models/User.cs new file mode 100644 index 000000000..af2025ba9 --- /dev/null +++ b/Ombi/Ombi.Api.Plex/Models/User.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; + +namespace Ombi.Api.Plex.Models +{ + public class User + { + public string email { get; set; } + public string uuid { get; set; } + public string joined_at { get; set; } + public string username { get; set; } + public string title { get; set; } + public string authentication_token { get; set; } + public Subscription subscription { get; set; } + public Roles roles { get; set; } + public List entitlements { get; set; } + public object confirmed_at { get; set; } + public int forum_id { get; set; } + } +} \ No newline at end of file diff --git a/Ombi/Ombi.Api.Plex/Models/UserRequest.cs b/Ombi/Ombi.Api.Plex/Models/UserRequest.cs new file mode 100644 index 000000000..9bd9c2844 --- /dev/null +++ b/Ombi/Ombi.Api.Plex/Models/UserRequest.cs @@ -0,0 +1,8 @@ +namespace Ombi.Api.Plex.Models +{ + public class UserRequest + { + public string login { get; set; } + public string password { get; set; } + } +} \ No newline at end of file diff --git a/Ombi/Ombi.Api.Plex/Ombi.Api.Plex.csproj b/Ombi/Ombi.Api.Plex/Ombi.Api.Plex.csproj new file mode 100644 index 000000000..154264cfa --- /dev/null +++ b/Ombi/Ombi.Api.Plex/Ombi.Api.Plex.csproj @@ -0,0 +1,15 @@ + + + + netstandard1.6 + + + + + + + + + + + \ No newline at end of file diff --git a/Ombi/Ombi.Api.Plex/PlexApi.cs b/Ombi/Ombi.Api.Plex/PlexApi.cs new file mode 100644 index 000000000..b0a6cf0f3 --- /dev/null +++ b/Ombi/Ombi.Api.Plex/PlexApi.cs @@ -0,0 +1,88 @@ +using System; +using System.Net.Http; +using System.Threading.Tasks; +using Ombi.Api.Plex.Models; +using Ombi.Api.Plex.Models.Server; +using Ombi.Api.Plex.Models.Status; + +namespace Ombi.Api.Plex +{ + public class PlexApi : IPlexApi + { + public PlexApi() + { + Api = new Api(); + } + + private Api Api { get; } + + private const string SignInUri = "https://plex.tv/users/sign_in.json"; + private const string FriendsUri = "https://plex.tv/pms/friends/all"; + private const string GetAccountUri = "https://plex.tv/users/account"; + private const string ServerUri = "https://plex.tv/pms/servers.xml"; + + /// + /// Sign into the Plex API + /// This is for authenticating users credentials with Plex + /// NOTE: Plex "Managed" users do not work + /// + /// + /// + /// + public async Task SignIn(UserRequest user) + { + var userModel = new PlexUserRequest + { + user = user + }; + var request = new Request(SignInUri, string.Empty, HttpMethod.Post); + + AddHeaders(request); + request.AddJsonBody(userModel); + + var obj = await Api.Request(request); + + return obj; + } + + public async Task GetStatus(string authToken, string uri) + { + var request = new Request(uri, string.Empty, HttpMethod.Get); + AddHeaders(request, authToken); + return await Api.Request(request); + } + + public async Task GetServer(string authToken) + { + var request = new Request(ServerUri, string.Empty, HttpMethod.Get, ContentType.Xml); + + AddHeaders(request, authToken); + + return await Api.Request(request); + } + + /// + /// Adds the required headers and also the authorization header + /// + /// + /// + private void AddHeaders(Request request, string authToken) + { + request.AddHeader("X-Plex-Token", authToken); + AddHeaders(request); + } + + /// + /// Adds the main required headers to the Plex Request + /// + /// + private void AddHeaders(Request request) + { + request.AddHeader("X-Plex-Client-Identifier", $"OmbiV3"); + request.AddHeader("X-Plex-Product", "Ombi"); + request.AddHeader("X-Plex-Version", "3"); + request.AddContentHeader("Content-Type", "application/json" ); + request.AddHeader("Accept","application/json"); + } + } +} diff --git a/Ombi/Ombi.Api/Api.cs b/Ombi/Ombi.Api/Api.cs index 824e8af9e..453a63bb2 100644 --- a/Ombi/Ombi.Api/Api.cs +++ b/Ombi/Ombi.Api/Api.cs @@ -1,6 +1,8 @@ using System; +using System.IO; using System.Net.Http; using System.Threading.Tasks; +using System.Xml.Serialization; using Newtonsoft.Json; namespace Ombi.Api @@ -41,6 +43,7 @@ namespace Ombi.Api foreach (var header in request.Headers) { httpRequestMessage.Headers.Add(header.Key, header.Value); + } using (var httpResponseMessage = await httpClient.SendAsync(httpRequestMessage)) { @@ -53,10 +56,23 @@ namespace Ombi.Api var receivedString = await data.ReadAsStringAsync(); - return JsonConvert.DeserializeObject(receivedString, Settings); + if (request.ContentType == ContentType.Json) + { + return JsonConvert.DeserializeObject(receivedString, Settings); + } + else + { + // XML + XmlSerializer serializer = new XmlSerializer(typeof(T)); + StringReader reader = new StringReader(receivedString); + var value = (T)serializer.Deserialize(reader); + return value; + } } } } } + + } } diff --git a/Ombi/Ombi.Api/ContentType.cs b/Ombi/Ombi.Api/ContentType.cs new file mode 100644 index 000000000..7a2d8ca71 --- /dev/null +++ b/Ombi/Ombi.Api/ContentType.cs @@ -0,0 +1,8 @@ +namespace Ombi.Api +{ + public enum ContentType + { + Json, + Xml + } +} \ No newline at end of file diff --git a/Ombi/Ombi.Api/Ombi.Api.csproj b/Ombi/Ombi.Api/Ombi.Api.csproj index b3d86c156..2fbb9976a 100644 --- a/Ombi/Ombi.Api/Ombi.Api.csproj +++ b/Ombi/Ombi.Api/Ombi.Api.csproj @@ -7,6 +7,7 @@ + \ No newline at end of file diff --git a/Ombi/Ombi.Api/Request.cs b/Ombi/Ombi.Api/Request.cs index a7a00501f..abc6a5669 100644 --- a/Ombi/Ombi.Api/Request.cs +++ b/Ombi/Ombi.Api/Request.cs @@ -9,13 +9,15 @@ namespace Ombi.Api { public class Request { - public Request(string endpoint, string baseUrl, HttpMethod http) + public Request(string endpoint, string baseUrl, HttpMethod http, ContentType contentType = ContentType.Json) { Endpoint = endpoint; BaseUrl = baseUrl; HttpMethod = http; + ContentType = contentType; } + public ContentType ContentType { get; } public string Endpoint { get; } public string BaseUrl { get; } public HttpMethod HttpMethod { get; } @@ -25,7 +27,10 @@ namespace Ombi.Api get { var sb = new StringBuilder(); - sb.Append(!BaseUrl.EndsWith("/") ? string.Format("{0}/", BaseUrl) : BaseUrl); + if (!string.IsNullOrEmpty(BaseUrl)) + { + sb.Append(!BaseUrl.EndsWith("/") ? string.Format("{0}/", BaseUrl) : BaseUrl); + } sb.Append(Endpoint.StartsWith("/") ? Endpoint.Remove(0, 1) : Endpoint); return sb.ToString(); } @@ -40,6 +45,7 @@ namespace Ombi.Api } public List> Headers { get; } = new List>(); + public List> ContentHeaders { get; } = new List>(); public object JsonBody { get; set; } @@ -64,10 +70,15 @@ namespace Ombi.Api { Headers.Add(new KeyValuePair(key, value)); } + public void AddContentHeader(string key, string value) + { + ContentHeaders.Add(new KeyValuePair(key, value)); + } public void AddJsonBody(object obj) { JsonBody = obj; } } + } \ No newline at end of file diff --git a/Ombi/Ombi.Core/Ombi.Core.csproj b/Ombi/Ombi.Core/Ombi.Core.csproj index 7bac40bb5..e2b8d857f 100644 --- a/Ombi/Ombi.Core/Ombi.Core.csproj +++ b/Ombi/Ombi.Core/Ombi.Core.csproj @@ -17,7 +17,7 @@ - + \ No newline at end of file diff --git a/Ombi/Ombi.DependencyInjection/IocExtensions.cs b/Ombi/Ombi.DependencyInjection/IocExtensions.cs index 57fae18d5..509e81d5f 100644 --- a/Ombi/Ombi.DependencyInjection/IocExtensions.cs +++ b/Ombi/Ombi.DependencyInjection/IocExtensions.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Authorization; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; +using Ombi.Api.Plex; using Ombi.Core; using Ombi.Core.Engine; using Ombi.Core.IdentityResolver; @@ -40,6 +41,7 @@ namespace Ombi.DependencyInjection public static IServiceCollection RegisterApi(this IServiceCollection services) { services.AddTransient(); + services.AddTransient(); return services; } diff --git a/Ombi/Ombi.DependencyInjection/Ombi.DependencyInjection.csproj b/Ombi/Ombi.DependencyInjection/Ombi.DependencyInjection.csproj index d776f14ed..a1142f694 100644 --- a/Ombi/Ombi.DependencyInjection/Ombi.DependencyInjection.csproj +++ b/Ombi/Ombi.DependencyInjection/Ombi.DependencyInjection.csproj @@ -6,19 +6,13 @@ + + + - - - ..\..\..\..\..\.nuget\packages\microsoft.aspnetcore.authorization\1.1.1\lib\netstandard1.3\Microsoft.AspNetCore.Authorization.dll - - - ..\..\..\..\..\.nuget\packages\microsoft.extensions.dependencyinjection.abstractions\1.1.0\lib\netstandard1.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll - - - \ No newline at end of file diff --git a/Ombi/Ombi.Helpers/Ombi.Helpers.csproj b/Ombi/Ombi.Helpers/Ombi.Helpers.csproj index 7cf7de058..3fc3d4752 100644 --- a/Ombi/Ombi.Helpers/Ombi.Helpers.csproj +++ b/Ombi/Ombi.Helpers/Ombi.Helpers.csproj @@ -7,15 +7,13 @@ + ..\..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.IdentityModel.dll - - ..\..\..\..\..\.nuget\packages\system.security.claims\4.3.0\ref\netstandard1.3\System.Security.Claims.dll - \ No newline at end of file diff --git a/Ombi/Ombi.TheMovieDbApi/Ombi.TheMovieDbApi.csproj b/Ombi/Ombi.TheMovieDbApi/Ombi.Api.TheMovieDb.csproj similarity index 83% rename from Ombi/Ombi.TheMovieDbApi/Ombi.TheMovieDbApi.csproj rename to Ombi/Ombi.TheMovieDbApi/Ombi.Api.TheMovieDb.csproj index 07b575cc8..e2e0a5381 100644 --- a/Ombi/Ombi.TheMovieDbApi/Ombi.TheMovieDbApi.csproj +++ b/Ombi/Ombi.TheMovieDbApi/Ombi.Api.TheMovieDb.csproj @@ -2,6 +2,7 @@ netstandard1.6 + Ombi.Api.TheMovieDb diff --git a/Ombi/Ombi.sln b/Ombi/Ombi.sln index 4519f2dc4..ac1f55b44 100644 --- a/Ombi/Ombi.sln +++ b/Ombi/Ombi.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26403.0 +VisualStudioVersion = 15.0.26228.9 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ombi", "Ombi\Ombi.csproj", "{C987AA67-AFE1-468F-ACD3-EAD5A48E1F6A}" EndProject @@ -16,7 +16,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ombi.Core", "Ombi.Core\Ombi EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Api", "Api", "{9293CA11-360A-4C20-A674-B9E794431BF5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ombi.TheMovieDbApi", "Ombi.TheMovieDbApi\Ombi.TheMovieDbApi.csproj", "{132DA282-5894-4570-8916-D8C18ED2CE84}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ombi.Api.TheMovieDb", "Ombi.TheMovieDbApi\Ombi.Api.TheMovieDb.csproj", "{132DA282-5894-4570-8916-D8C18ED2CE84}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ombi.Api", "Ombi.Api\Ombi.Api.csproj", "{EA31F915-31F9-4318-B521-1500CDF40DDF}" EndProject @@ -32,6 +32,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Mappers", "Mappers", "{025F EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DI", "DI", "{410F36CF-9C60-428A-B191-6FD90610991A}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ombi.Api.Plex", "Ombi.Api.Plex\Ombi.Api.Plex.csproj", "{2E1A7B91-F29B-42BC-8F1E-1CF2DCC389BA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -70,6 +72,10 @@ Global {63E63511-1C7F-4162-8F92-8F7391B3C8A3}.Debug|Any CPU.Build.0 = Debug|Any CPU {63E63511-1C7F-4162-8F92-8F7391B3C8A3}.Release|Any CPU.ActiveCfg = Release|Any CPU {63E63511-1C7F-4162-8F92-8F7391B3C8A3}.Release|Any CPU.Build.0 = Release|Any CPU + {2E1A7B91-F29B-42BC-8F1E-1CF2DCC389BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2E1A7B91-F29B-42BC-8F1E-1CF2DCC389BA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2E1A7B91-F29B-42BC-8F1E-1CF2DCC389BA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2E1A7B91-F29B-42BC-8F1E-1CF2DCC389BA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -79,5 +85,6 @@ Global {EA31F915-31F9-4318-B521-1500CDF40DDF} = {9293CA11-360A-4C20-A674-B9E794431BF5} {B39E4558-C557-48E7-AA74-19C5CD809617} = {410F36CF-9C60-428A-B191-6FD90610991A} {63E63511-1C7F-4162-8F92-8F7391B3C8A3} = {025FB189-2FFB-4F43-A64B-6F1B5A0D2065} + {2E1A7B91-F29B-42BC-8F1E-1CF2DCC389BA} = {9293CA11-360A-4C20-A674-B9E794431BF5} EndGlobalSection EndGlobal diff --git a/Ombi/Ombi/Controllers/PlexController.cs b/Ombi/Ombi/Controllers/PlexController.cs new file mode 100644 index 000000000..322518c9b --- /dev/null +++ b/Ombi/Ombi/Controllers/PlexController.cs @@ -0,0 +1,50 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Ombi.Api.Plex; +using Ombi.Api.Plex.Models; +using Ombi.Core.Engine; +using Ombi.Core.Models.Requests; +using Ombi.Core.Models.Search; +using Ombi.Core.Settings; +using Ombi.Core.Settings.Models.External; + +namespace Ombi.Controllers +{ + public class PlexController : BaseV1ApiController + { + public PlexController(IPlexApi plexApi, ISettingsService plexSettings) + { + PlexApi = plexApi; + PlexSettings = plexSettings; + } + + private IPlexApi PlexApi { get; } + private ISettingsService PlexSettings { get; } + + [HttpPost] + public async Task SignIn([FromBody] UserRequest request) + { + var result = await PlexApi.SignIn(request); + if (!string.IsNullOrEmpty(result.user?.authentication_token)) + { + var server = await PlexApi.GetServer(result.user.authentication_token); + var firstServer = server.Server.FirstOrDefault(); + await PlexSettings.SaveSettingsAsync(new PlexSettings + { + Enable = true, + PlexAuthToken = result.user.authentication_token, + Ip = firstServer.LocalAddresses, + MachineIdentifier = firstServer.MachineIdentifier, + Port = int.Parse(firstServer.Port), + Ssl = firstServer.Scheme != "http", + }); + } + + return result; + } + + + } +} diff --git a/Ombi/Ombi/Ombi.csproj b/Ombi/Ombi/Ombi.csproj index da1c749d6..10eacc179 100644 --- a/Ombi/Ombi/Ombi.csproj +++ b/Ombi/Ombi/Ombi.csproj @@ -7,6 +7,10 @@ + + + + PreserveNewest @@ -16,6 +20,11 @@ + + + + PreserveNewest + @@ -52,39 +61,13 @@ - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - - + + + + + + + @@ -113,21 +96,23 @@ + - + ..\..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Configuration.dll - - ..\..\..\..\..\.nuget\packages\system.security.cryptography.csp\4.3.0\ref\netstandard1.3\System.Security.Cryptography.Csp.dll - + + + + diff --git a/Ombi/Ombi/Styles/base.scss b/Ombi/Ombi/Styles/base.scss index 7755b64e6..f8ca8f348 100644 --- a/Ombi/Ombi/Styles/base.scss +++ b/Ombi/Ombi/Styles/base.scss @@ -713,4 +713,10 @@ body { .ui-widget-content { border: 1px solid $form-color-lighter $i; background: $form-color $i; +} + +// PrimeNg Overide + +.ui-growl-item{ + margin-top:35px $i; } \ No newline at end of file diff --git a/Ombi/Ombi/wwwroot/app/app.component.html b/Ombi/Ombi/wwwroot/app/app.component.html index 1d28e3abe..b3ea68d54 100644 --- a/Ombi/Ombi/wwwroot/app/app.component.html +++ b/Ombi/Ombi/wwwroot/app/app.component.html @@ -1,4 +1,4 @@ - +