diff --git a/.gitattributes b/.gitattributes index 210f21789..4bf8b8c28 100644 --- a/.gitattributes +++ b/.gitattributes @@ -66,6 +66,3 @@ PlexRequests.UI/Content/* linguist-vendored PlexRequests.UI/Content/* linguist-vendored base.scss linguist-vendored=false -requests-1.7.js linguist-vendored=false -search-1.7.js linguist-vendored=false -site-1.7.js linguist-vendored=false diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index aa693030a..09b8fe865 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,22 +1,24 @@ -If this is a bug report please make sure you have filled the following in: -(If it's not a bug and a feature request then just remove the below) - -#### Plex Requests.Net Version: - - -#### Operating System: - - -#### Mono Version: - - -#### Applicable Logs (from `/logs/` directory or the Admin page): - -``` -Logs go here (Please make sure you remove any personal information from the logs) -``` - - -#### Reproduction Steps: - -Please include any steps to reproduce the issue, this the request that is causing the problem etc. \ No newline at end of file +If this is a bug report please make sure you have filled the following in: +(If it's not a bug and a feature request then just remove the below) + +#### Plex Requests.Net Version: + +#### update Branch: + + +#### Operating System: + + +#### Mono Version: + + +#### Applicable Logs (from `/logs/` directory or the Admin page): + +``` +Logs go here (Please make sure you remove any personal information from the logs) +``` + + +#### Reproduction Steps: + +Please include any steps to reproduce the issue, this the request that is causing the problem etc. diff --git a/.travis.yml b/.travis.yml index 255ac37d6..9657145fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ -language: csharp -solution: PlexRequests.sln -install: - - mono Tools/nuget.exe restore PlexRequests.sln - - nuget install NUnit.Runners -OutputDirectory testrunner -script: +language: csharp +solution: PlexRequests.sln +install: + - mono Tools/nuget.exe restore PlexRequests.sln + - nuget install NUnit.Runners -OutputDirectory testrunner +script: - xbuild /p:Configuration=Release PlexRequests.sln /p:TargetFrameworkVersion="v4.5" \ No newline at end of file diff --git a/PlexRequests.Api.Interfaces/IApiRequest.cs b/PlexRequests.Api.Interfaces/IApiRequest.cs index f2fa72f44..396551dba 100644 --- a/PlexRequests.Api.Interfaces/IApiRequest.cs +++ b/PlexRequests.Api.Interfaces/IApiRequest.cs @@ -1,40 +1,40 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: IApiRequest.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; - -using RestSharp; - -namespace PlexRequests.Api.Interfaces -{ - public interface IApiRequest - { - T Execute(IRestRequest request, Uri baseUri) where T : new(); - IRestResponse Execute(IRestRequest request, Uri baseUri); - T ExecuteXml(IRestRequest request, Uri baseUri) where T : class; - T ExecuteJson(IRestRequest request, Uri baseUri) where T : new(); - } -} +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: IApiRequest.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; + +using RestSharp; + +namespace PlexRequests.Api.Interfaces +{ + public interface IApiRequest + { + T Execute(IRestRequest request, Uri baseUri) where T : new(); + IRestResponse Execute(IRestRequest request, Uri baseUri); + T ExecuteXml(IRestRequest request, Uri baseUri) where T : class; + T ExecuteJson(IRestRequest request, Uri baseUri) where T : new(); + } +} diff --git a/PlexRequests.Api.Interfaces/IHeadphonesApi.cs b/PlexRequests.Api.Interfaces/IHeadphonesApi.cs index a895f1689..edd041fd4 100644 --- a/PlexRequests.Api.Interfaces/IHeadphonesApi.cs +++ b/PlexRequests.Api.Interfaces/IHeadphonesApi.cs @@ -1,44 +1,44 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: IHeadphonesApi.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; -using System.Collections.Generic; -using System.Threading.Tasks; - -using PlexRequests.Api.Models.Music; - -namespace PlexRequests.Api.Interfaces -{ - public interface IHeadphonesApi - { - Task AddAlbum(string apiKey, Uri baseUrl, string albumId); - HeadphonesVersion GetVersion(string apiKey, Uri baseUrl); - Task AddArtist(string apiKey, Uri baseUrl, string artistId); - Task QueueAlbum(string apiKey, Uri baseUrl, string albumId); - Task> GetIndex(string apiKey, Uri baseUrl); - Task RefreshArtist(string apiKey, Uri baseUrl, string artistId); - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: IHeadphonesApi.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; +using System.Collections.Generic; +using System.Threading.Tasks; + +using PlexRequests.Api.Models.Music; + +namespace PlexRequests.Api.Interfaces +{ + public interface IHeadphonesApi + { + Task AddAlbum(string apiKey, Uri baseUrl, string albumId); + HeadphonesVersion GetVersion(string apiKey, Uri baseUrl); + Task AddArtist(string apiKey, Uri baseUrl, string artistId); + Task QueueAlbum(string apiKey, Uri baseUrl, string albumId); + Task> GetIndex(string apiKey, Uri baseUrl); + Task RefreshArtist(string apiKey, Uri baseUrl, string artistId); + } } \ No newline at end of file diff --git a/PlexRequests.Api.Interfaces/IPushbulletApi.cs b/PlexRequests.Api.Interfaces/IPushbulletApi.cs index 5df902d4c..7d9b486b1 100644 --- a/PlexRequests.Api.Interfaces/IPushbulletApi.cs +++ b/PlexRequests.Api.Interfaces/IPushbulletApi.cs @@ -1,45 +1,45 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: IPushbulletApi.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.Threading.Tasks; - -using PlexRequests.Api.Models.Notifications; - -namespace PlexRequests.Api.Interfaces -{ - public interface IPushbulletApi - { - /// - /// Pushes the specified message. - /// - /// The access token. - /// The title. - /// The message. - /// The device identifier. - /// - Task PushAsync(string accessToken, string title, string message, string deviceIdentifier = default(string)); - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: IPushbulletApi.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.Threading.Tasks; + +using PlexRequests.Api.Models.Notifications; + +namespace PlexRequests.Api.Interfaces +{ + public interface IPushbulletApi + { + /// + /// Pushes the specified message. + /// + /// The access token. + /// The title. + /// The message. + /// The device identifier. + /// + Task PushAsync(string accessToken, string title, string message, string deviceIdentifier = default(string)); + } } \ No newline at end of file diff --git a/PlexRequests.Api.Interfaces/IPushoverApi.cs b/PlexRequests.Api.Interfaces/IPushoverApi.cs index 15f93f596..fb1179c28 100644 --- a/PlexRequests.Api.Interfaces/IPushoverApi.cs +++ b/PlexRequests.Api.Interfaces/IPushoverApi.cs @@ -1,37 +1,37 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: IPushoverApi.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.Threading.Tasks; - -using PlexRequests.Api.Models.Notifications; - -namespace PlexRequests.Api.Interfaces -{ - public interface IPushoverApi - { - Task PushAsync(string accessToken, string message, string userToken); - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: IPushoverApi.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.Threading.Tasks; + +using PlexRequests.Api.Models.Notifications; + +namespace PlexRequests.Api.Interfaces +{ + public interface IPushoverApi + { + Task PushAsync(string accessToken, string message, string userToken); + } } \ No newline at end of file diff --git a/PlexRequests.Api.Interfaces/ISickRageApi.cs b/PlexRequests.Api.Interfaces/ISickRageApi.cs index 13cfacd84..7363d676f 100644 --- a/PlexRequests.Api.Interfaces/ISickRageApi.cs +++ b/PlexRequests.Api.Interfaces/ISickRageApi.cs @@ -1,45 +1,45 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: ISickRageApi.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; -using System.Threading.Tasks; -using PlexRequests.Api.Models.SickRage; - -namespace PlexRequests.Api.Interfaces -{ - public interface ISickRageApi - { - Task AddSeries(int tvdbId, int seasoncount, int[] seasons, string quality, string apiKey, - Uri baseUrl); - - SickRagePing Ping(string apiKey, Uri baseUrl); - - Task AddSeason(int tvdbId, int season, string apiKey, Uri baseUrl); - - Task GetShows(string apiKey, Uri baseUrl); - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: ISickRageApi.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; +using System.Threading.Tasks; +using PlexRequests.Api.Models.SickRage; + +namespace PlexRequests.Api.Interfaces +{ + public interface ISickRageApi + { + Task AddSeries(int tvdbId, int seasoncount, int[] seasons, string quality, string apiKey, + Uri baseUrl); + + SickRagePing Ping(string apiKey, Uri baseUrl); + + Task AddSeason(int tvdbId, int season, string apiKey, Uri baseUrl); + + Task GetShows(string apiKey, Uri baseUrl); + } } \ No newline at end of file diff --git a/PlexRequests.Api.Interfaces/PlexRequests.Api.Interfaces.csproj b/PlexRequests.Api.Interfaces/PlexRequests.Api.Interfaces.csproj index cf321d344..749739acc 100644 --- a/PlexRequests.Api.Interfaces/PlexRequests.Api.Interfaces.csproj +++ b/PlexRequests.Api.Interfaces/PlexRequests.Api.Interfaces.csproj @@ -1,78 +1,78 @@ - - - - - Debug - AnyCPU - {95834072-A675-415D-AA8F-877C91623810} - Library - Properties - PlexRequests.Api.Interfaces - PlexRequests.Api.Interfaces - v4.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\RestSharp.105.2.3\lib\net45\RestSharp.dll - True - - - - - - - - - - - - - - - - - - - - - - - - - - {CB37A5F8-6DFC-4554-99D3-A42B502E4591} - PlexRequests.Api.Models - - - - - - - - + + + + + Debug + AnyCPU + {95834072-A675-415D-AA8F-877C91623810} + Library + Properties + PlexRequests.Api.Interfaces + PlexRequests.Api.Interfaces + v4.5 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\RestSharp.105.2.3\lib\net45\RestSharp.dll + True + + + + + + + + + + + + + + + + + + + + + + + + + + {CB37A5F8-6DFC-4554-99D3-A42B502E4591} + PlexRequests.Api.Models + + + + + + + + \ No newline at end of file diff --git a/PlexRequests.Api.Interfaces/Properties/AssemblyInfo.cs b/PlexRequests.Api.Interfaces/Properties/AssemblyInfo.cs index e8fb7c60d..0ad652e33 100644 --- a/PlexRequests.Api.Interfaces/Properties/AssemblyInfo.cs +++ b/PlexRequests.Api.Interfaces/Properties/AssemblyInfo.cs @@ -1,38 +1,38 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("PlexRequests.Api.Interfaces")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("PlexRequests.Api.Interfaces")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("95834072-a675-415d-aa8f-877c91623810")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] - -[assembly: AssemblyInformationalVersionAttribute("1.0.0.0")] +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("PlexRequests.Api.Interfaces")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PlexRequests.Api.Interfaces")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("95834072-a675-415d-aa8f-877c91623810")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] + +[assembly: AssemblyInformationalVersionAttribute("1.0.0.0")] diff --git a/PlexRequests.Api.Models/Movie/CouchPotatoMovies.cs b/PlexRequests.Api.Models/Movie/CouchPotatoMovies.cs index 33399179c..672297588 100644 --- a/PlexRequests.Api.Models/Movie/CouchPotatoMovies.cs +++ b/PlexRequests.Api.Models/Movie/CouchPotatoMovies.cs @@ -1,12 +1,12 @@ -using System.Collections.Generic; - -namespace PlexRequests.Api.Models.Movie -{ - public class CouchPotatoMovies - { - public List movies { get; set; } - public int total { get; set; } - public bool success { get; set; } - public bool empty { get; set; } - } -} +using System.Collections.Generic; + +namespace PlexRequests.Api.Models.Movie +{ + public class CouchPotatoMovies + { + public List movies { get; set; } + public int total { get; set; } + public bool success { get; set; } + public bool empty { get; set; } + } +} diff --git a/PlexRequests.Api.Models/Movie/CouchPotatoProfiles.cs b/PlexRequests.Api.Models/Movie/CouchPotatoProfiles.cs index 2da2cd221..41fc02379 100644 --- a/PlexRequests.Api.Models/Movie/CouchPotatoProfiles.cs +++ b/PlexRequests.Api.Models/Movie/CouchPotatoProfiles.cs @@ -1,58 +1,58 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: CouchPotatoProfiles.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 Newtonsoft.Json; -using Newtonsoft.Json.Serialization; - -namespace PlexRequests.Api.Models.Movie -{ - public class ProfileList - { - public bool core { get; set; } - public bool hide { get; set; } - public string _rev { get; set; } - public List finish { get; set; } - public List qualities { get; set; } - public string _id { get; set; } - public string _t { get; set; } - public string label { get; set; } - public int minimum_score { get; set; } - public List stop_after { get; set; } - public List wait_for { get; set; } - public int order { get; set; } - [JsonProperty(PropertyName = "3d")] - public List threeD { get; set; } - } - - public class CouchPotatoProfiles - { - public List list { get; set; } - public bool success { get; set; } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: CouchPotatoProfiles.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 Newtonsoft.Json; +using Newtonsoft.Json.Serialization; + +namespace PlexRequests.Api.Models.Movie +{ + public class ProfileList + { + public bool core { get; set; } + public bool hide { get; set; } + public string _rev { get; set; } + public List finish { get; set; } + public List qualities { get; set; } + public string _id { get; set; } + public string _t { get; set; } + public string label { get; set; } + public int minimum_score { get; set; } + public List stop_after { get; set; } + public List wait_for { get; set; } + public int order { get; set; } + [JsonProperty(PropertyName = "3d")] + public List threeD { get; set; } + } + + public class CouchPotatoProfiles + { + public List list { get; set; } + public bool success { get; set; } + } } \ No newline at end of file diff --git a/PlexRequests.Api.Models/Movie/CouchPotatoStatus.cs b/PlexRequests.Api.Models/Movie/CouchPotatoStatus.cs index 7f20a7596..fc527fd63 100644 --- a/PlexRequests.Api.Models/Movie/CouchPotatoStatus.cs +++ b/PlexRequests.Api.Models/Movie/CouchPotatoStatus.cs @@ -1,13 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace PlexRequests.Api.Models.Movie -{ - public class CouchPotatoStatus - { - public bool success { get; set; } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PlexRequests.Api.Models.Movie +{ + public class CouchPotatoStatus + { + public bool success { get; set; } + } +} diff --git a/PlexRequests.Api.Models/Music/HeadphonesAlbumSearchResult.cs b/PlexRequests.Api.Models/Music/HeadphonesAlbumSearchResult.cs index 8aa4684c6..bcbd8e4e6 100644 --- a/PlexRequests.Api.Models/Music/HeadphonesAlbumSearchResult.cs +++ b/PlexRequests.Api.Models/Music/HeadphonesAlbumSearchResult.cs @@ -1,45 +1,45 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: HeadphonesAlbumSearchResult.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 PlexRequests.Api.Models.Music -{ - public class HeadphonesAlbumSearchResult - { - public string rgid { get; set; } - public string albumurl { get; set; } - public string tracks { get; set; } - public string date { get; set; } - public string id { get; set; } // Artist ID - public string rgtype { get; set; } - public string title { get; set; } - public string url { get; set; } - public string country { get; set; } - public string albumid { get; set; } // AlbumId - public int score { get; set; } - public string uniquename { get; set; } - public string formats { get; set; } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: HeadphonesAlbumSearchResult.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 PlexRequests.Api.Models.Music +{ + public class HeadphonesAlbumSearchResult + { + public string rgid { get; set; } + public string albumurl { get; set; } + public string tracks { get; set; } + public string date { get; set; } + public string id { get; set; } // Artist ID + public string rgtype { get; set; } + public string title { get; set; } + public string url { get; set; } + public string country { get; set; } + public string albumid { get; set; } // AlbumId + public int score { get; set; } + public string uniquename { get; set; } + public string formats { get; set; } + } } \ No newline at end of file diff --git a/PlexRequests.Api.Models/Music/HeadphonesArtistSearchResult.cs b/PlexRequests.Api.Models/Music/HeadphonesArtistSearchResult.cs index 15c574277..0d822fe59 100644 --- a/PlexRequests.Api.Models/Music/HeadphonesArtistSearchResult.cs +++ b/PlexRequests.Api.Models/Music/HeadphonesArtistSearchResult.cs @@ -1,37 +1,37 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: HeadphonesSearchResult.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 PlexRequests.Api.Models.Music -{ - public class HeadphonesArtistSearchResult - { - public string url { get; set; } // MusicBrainz url - public int score { get; set; } // Search Match score? - public string name { get; set; } // Artist Name - public string uniquename { get; set; } // Artist Unique Name - public string id { get; set; } // Artist Unique ID for MusicBrainz - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: HeadphonesSearchResult.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 PlexRequests.Api.Models.Music +{ + public class HeadphonesArtistSearchResult + { + public string url { get; set; } // MusicBrainz url + public int score { get; set; } // Search Match score? + public string name { get; set; } // Artist Name + public string uniquename { get; set; } // Artist Unique Name + public string id { get; set; } // Artist Unique ID for MusicBrainz + } } \ No newline at end of file diff --git a/PlexRequests.Api.Models/Music/HeadphonesVersion.cs b/PlexRequests.Api.Models/Music/HeadphonesVersion.cs index 1ee6e16e8..b700d7214 100644 --- a/PlexRequests.Api.Models/Music/HeadphonesVersion.cs +++ b/PlexRequests.Api.Models/Music/HeadphonesVersion.cs @@ -1,37 +1,37 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: HeadphonesVersion.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 PlexRequests.Api.Models.Music -{ - public class HeadphonesVersion - { - public string install_type { get; set; } - public object current_version { get; set; } - public string git_path { get; set; } - public string latest_version { get; set; } - public int commits_behind { get; set; } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: HeadphonesVersion.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 PlexRequests.Api.Models.Music +{ + public class HeadphonesVersion + { + public string install_type { get; set; } + public object current_version { get; set; } + public string git_path { get; set; } + public string latest_version { get; set; } + public int commits_behind { get; set; } + } } \ No newline at end of file diff --git a/PlexRequests.Api.Models/Music/MusicBrainzReleaseInfo.cs b/PlexRequests.Api.Models/Music/MusicBrainzReleaseInfo.cs index b3ca2ee62..683a36a2c 100644 --- a/PlexRequests.Api.Models/Music/MusicBrainzReleaseInfo.cs +++ b/PlexRequests.Api.Models/Music/MusicBrainzReleaseInfo.cs @@ -1,68 +1,68 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: MusicBrainzReleaseInfo.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 Newtonsoft.Json; - -namespace PlexRequests.Api.Models.Music -{ - public class CoverArtArchive - { - public int count { get; set; } - public bool back { get; set; } - public bool artwork { get; set; } - public bool front { get; set; } - public bool darkened { get; set; } - } - - - public class MusicBrainzReleaseInfo - { - [JsonProperty(PropertyName = "artist-credit")] - public List ArtistCredits { get; set; } - public string date { get; set; } - public string status { get; set; } - public string asin { get; set; } - public string title { get; set; } - public string quality { get; set; } - public string country { get; set; } - public string packaging { get; set; } - - [JsonProperty(PropertyName = "text-representation")] - public TextRepresentation TextRepresentation { get; set; } - - [JsonProperty(PropertyName = "cover-art-archive")] - public CoverArtArchive CoverArtArchive { get; set; } - public string barcode { get; set; } - public string disambiguation { get; set; } - - [JsonProperty(PropertyName = "release-events")] - public List ReleaseEvents { get; set; } - public string id { get; set; } - } - +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: MusicBrainzReleaseInfo.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 Newtonsoft.Json; + +namespace PlexRequests.Api.Models.Music +{ + public class CoverArtArchive + { + public int count { get; set; } + public bool back { get; set; } + public bool artwork { get; set; } + public bool front { get; set; } + public bool darkened { get; set; } + } + + + public class MusicBrainzReleaseInfo + { + [JsonProperty(PropertyName = "artist-credit")] + public List ArtistCredits { get; set; } + public string date { get; set; } + public string status { get; set; } + public string asin { get; set; } + public string title { get; set; } + public string quality { get; set; } + public string country { get; set; } + public string packaging { get; set; } + + [JsonProperty(PropertyName = "text-representation")] + public TextRepresentation TextRepresentation { get; set; } + + [JsonProperty(PropertyName = "cover-art-archive")] + public CoverArtArchive CoverArtArchive { get; set; } + public string barcode { get; set; } + public string disambiguation { get; set; } + + [JsonProperty(PropertyName = "release-events")] + public List ReleaseEvents { get; set; } + public string id { get; set; } + } + } \ No newline at end of file diff --git a/PlexRequests.Api.Models/Notifications/PushbulletPush.cs b/PlexRequests.Api.Models/Notifications/PushbulletPush.cs index d2f63efd1..755dc240d 100644 --- a/PlexRequests.Api.Models/Notifications/PushbulletPush.cs +++ b/PlexRequests.Api.Models/Notifications/PushbulletPush.cs @@ -1,38 +1,38 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: PushbulletPush.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 Newtonsoft.Json; - -namespace PlexRequests.Api.Models.Notifications -{ - public class PushbulletPush - { - public string body { get; set; } - public string title { get; set; } - public string type { get; set; } - public string device_iden { get; set; } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: PushbulletPush.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 Newtonsoft.Json; + +namespace PlexRequests.Api.Models.Notifications +{ + public class PushbulletPush + { + public string body { get; set; } + public string title { get; set; } + public string type { get; set; } + public string device_iden { get; set; } + } } \ No newline at end of file diff --git a/PlexRequests.Api.Models/Notifications/PushbulletResponse.cs b/PlexRequests.Api.Models/Notifications/PushbulletResponse.cs index eda3c41c7..4c4daede9 100644 --- a/PlexRequests.Api.Models/Notifications/PushbulletResponse.cs +++ b/PlexRequests.Api.Models/Notifications/PushbulletResponse.cs @@ -1,48 +1,48 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: PushbulletResponse.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 PlexRequests.Api.Models.Notifications -{ - public class PushbulletResponse - { - public bool active { get; set; } - public string iden { get; set; } - public double created { get; set; } - public double modified { get; set; } - public string type { get; set; } - public bool dismissed { get; set; } - public string direction { get; set; } - public string sender_iden { get; set; } - public string sender_email { get; set; } - public string sender_email_normalized { get; set; } - public string sender_name { get; set; } - public string receiver_iden { get; set; } - public string receiver_email { get; set; } - public string receiver_email_normalized { get; set; } - public string title { get; set; } - public string body { get; set; } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: PushbulletResponse.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 PlexRequests.Api.Models.Notifications +{ + public class PushbulletResponse + { + public bool active { get; set; } + public string iden { get; set; } + public double created { get; set; } + public double modified { get; set; } + public string type { get; set; } + public bool dismissed { get; set; } + public string direction { get; set; } + public string sender_iden { get; set; } + public string sender_email { get; set; } + public string sender_email_normalized { get; set; } + public string sender_name { get; set; } + public string receiver_iden { get; set; } + public string receiver_email { get; set; } + public string receiver_email_normalized { get; set; } + public string title { get; set; } + public string body { get; set; } + } } \ No newline at end of file diff --git a/PlexRequests.Api.Models/Notifications/PushoverResponse.cs b/PlexRequests.Api.Models/Notifications/PushoverResponse.cs index 94849fba1..1b31f80f1 100644 --- a/PlexRequests.Api.Models/Notifications/PushoverResponse.cs +++ b/PlexRequests.Api.Models/Notifications/PushoverResponse.cs @@ -1,34 +1,34 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: PushoverResponse.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 PlexRequests.Api.Models.Notifications -{ - public class PushoverResponse - { - public int status { get; set; } - public string request { get; set; } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: PushoverResponse.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 PlexRequests.Api.Models.Notifications +{ + public class PushoverResponse + { + public int status { get; set; } + public string request { get; set; } + } } \ No newline at end of file diff --git a/PlexRequests.Api.Models/Plex/PlexError.cs b/PlexRequests.Api.Models/Plex/PlexError.cs index f62a0a7f0..d5be3a374 100644 --- a/PlexRequests.Api.Models/Plex/PlexError.cs +++ b/PlexRequests.Api.Models/Plex/PlexError.cs @@ -1,39 +1,39 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: PlexError.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.Xml.Serialization; - -namespace PlexRequests.Api.Models.Plex -{ - [XmlRoot(ElementName = "errors")] - public class PlexError - { - [XmlElement(ElementName = "error")] - public string Error { get; set; } - - } -} +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: PlexError.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.Xml.Serialization; + +namespace PlexRequests.Api.Models.Plex +{ + [XmlRoot(ElementName = "errors")] + public class PlexError + { + [XmlElement(ElementName = "error")] + public string Error { get; set; } + + } +} diff --git a/PlexRequests.Api.Models/Plex/PlexLibraries.cs b/PlexRequests.Api.Models/Plex/PlexLibraries.cs index 0be7185a7..d9ae732d8 100644 --- a/PlexRequests.Api.Models/Plex/PlexLibraries.cs +++ b/PlexRequests.Api.Models/Plex/PlexLibraries.cs @@ -1,22 +1,22 @@ -using System.Collections.Generic; -using System.Xml.Serialization; - -namespace PlexRequests.Api.Models.Plex -{ - [XmlRoot(ElementName = "MediaContainer")] - public class PlexLibraries - { - [XmlElement(ElementName = "Directory")] - public List Directories { get; set; } - } - - [XmlRoot(ElementName = "Location")] - public partial class Location - { - [XmlElement(ElementName = "id")] - public int id { get; set; } - [XmlElement(ElementName = "path")] - public string path { get; set; } - } - -} +using System.Collections.Generic; +using System.Xml.Serialization; + +namespace PlexRequests.Api.Models.Plex +{ + [XmlRoot(ElementName = "MediaContainer")] + public class PlexLibraries + { + [XmlElement(ElementName = "Directory")] + public List Directories { get; set; } + } + + [XmlRoot(ElementName = "Location")] + public partial class Location + { + [XmlElement(ElementName = "id")] + public int id { get; set; } + [XmlElement(ElementName = "path")] + public string path { get; set; } + } + +} diff --git a/PlexRequests.Api.Models/Plex/PlexStatus.cs b/PlexRequests.Api.Models/Plex/PlexStatus.cs index 7775be50b..db20e0f44 100644 --- a/PlexRequests.Api.Models/Plex/PlexStatus.cs +++ b/PlexRequests.Api.Models/Plex/PlexStatus.cs @@ -1,91 +1,91 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Serialization; - -namespace PlexRequests.Api.Models.Plex -{ - [XmlRoot(ElementName = "Directory")] - public class Directory - { - [XmlAttribute(AttributeName = "count")] - public string Count { get; set; } - [XmlAttribute(AttributeName = "key")] - public string Key { get; set; } - [XmlAttribute(AttributeName = "title")] - public string Title { get; set; } - [XmlAttribute(AttributeName = "type")] - public string type { get; set; } - } - - [XmlRoot(ElementName = "MediaContainer")] - public class PlexStatus - { - [XmlElement(ElementName = "Directory")] - public List Directory { get; set; } - [XmlAttribute(AttributeName = "size")] - public string Size { get; set; } - [XmlAttribute(AttributeName = "allowCameraUpload")] - public string AllowCameraUpload { get; set; } - [XmlAttribute(AttributeName = "allowChannelAccess")] - public string AllowChannelAccess { get; set; } - [XmlAttribute(AttributeName = "allowMediaDeletion")] - public string AllowMediaDeletion { get; set; } - [XmlAttribute(AttributeName = "allowSync")] - public string AllowSync { get; set; } - [XmlAttribute(AttributeName = "backgroundProcessing")] - public string BackgroundProcessing { get; set; } - [XmlAttribute(AttributeName = "certificate")] - public string Certificate { get; set; } - [XmlAttribute(AttributeName = "companionProxy")] - public string CompanionProxy { get; set; } - [XmlAttribute(AttributeName = "friendlyName")] - public string FriendlyName { get; set; } - [XmlAttribute(AttributeName = "machineIdentifier")] - public string MachineIdentifier { get; set; } - [XmlAttribute(AttributeName = "multiuser")] - public string Multiuser { get; set; } - [XmlAttribute(AttributeName = "myPlex")] - public string MyPlex { get; set; } - [XmlAttribute(AttributeName = "myPlexMappingState")] - public string MyPlexMappingState { get; set; } - [XmlAttribute(AttributeName = "myPlexSigninState")] - public string MyPlexSigninState { get; set; } - [XmlAttribute(AttributeName = "myPlexSubscription")] - public string MyPlexSubscription { get; set; } - [XmlAttribute(AttributeName = "myPlexUsername")] - public string MyPlexUsername { get; set; } - [XmlAttribute(AttributeName = "platform")] - public string Platform { get; set; } - [XmlAttribute(AttributeName = "platformVersion")] - public string PlatformVersion { get; set; } - [XmlAttribute(AttributeName = "requestParametersInCookie")] - public string RequestParametersInCookie { get; set; } - [XmlAttribute(AttributeName = "sync")] - public string Sync { get; set; } - [XmlAttribute(AttributeName = "transcoderActiveVideoSessions")] - public string TranscoderActiveVideoSessions { get; set; } - [XmlAttribute(AttributeName = "transcoderAudio")] - public string TranscoderAudio { get; set; } - [XmlAttribute(AttributeName = "transcoderLyrics")] - public string TranscoderLyrics { get; set; } - [XmlAttribute(AttributeName = "transcoderPhoto")] - public string TranscoderPhoto { get; set; } - [XmlAttribute(AttributeName = "transcoderSubtitles")] - public string TranscoderSubtitles { get; set; } - [XmlAttribute(AttributeName = "transcoderVideo")] - public string TranscoderVideo { get; set; } - [XmlAttribute(AttributeName = "transcoderVideoBitrates")] - public string TranscoderVideoBitrates { get; set; } - [XmlAttribute(AttributeName = "transcoderVideoQualities")] - public string TranscoderVideoQualities { get; set; } - [XmlAttribute(AttributeName = "transcoderVideoResolutions")] - public string TranscoderVideoResolutions { get; set; } - [XmlAttribute(AttributeName = "updatedAt")] - public string UpdatedAt { get; set; } - [XmlAttribute(AttributeName = "version")] - public string Version { get; set; } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace PlexRequests.Api.Models.Plex +{ + [XmlRoot(ElementName = "Directory")] + public class Directory + { + [XmlAttribute(AttributeName = "count")] + public string Count { get; set; } + [XmlAttribute(AttributeName = "key")] + public string Key { get; set; } + [XmlAttribute(AttributeName = "title")] + public string Title { get; set; } + [XmlAttribute(AttributeName = "type")] + public string type { get; set; } + } + + [XmlRoot(ElementName = "MediaContainer")] + public class PlexStatus + { + [XmlElement(ElementName = "Directory")] + public List Directory { get; set; } + [XmlAttribute(AttributeName = "size")] + public string Size { get; set; } + [XmlAttribute(AttributeName = "allowCameraUpload")] + public string AllowCameraUpload { get; set; } + [XmlAttribute(AttributeName = "allowChannelAccess")] + public string AllowChannelAccess { get; set; } + [XmlAttribute(AttributeName = "allowMediaDeletion")] + public string AllowMediaDeletion { get; set; } + [XmlAttribute(AttributeName = "allowSync")] + public string AllowSync { get; set; } + [XmlAttribute(AttributeName = "backgroundProcessing")] + public string BackgroundProcessing { get; set; } + [XmlAttribute(AttributeName = "certificate")] + public string Certificate { get; set; } + [XmlAttribute(AttributeName = "companionProxy")] + public string CompanionProxy { get; set; } + [XmlAttribute(AttributeName = "friendlyName")] + public string FriendlyName { get; set; } + [XmlAttribute(AttributeName = "machineIdentifier")] + public string MachineIdentifier { get; set; } + [XmlAttribute(AttributeName = "multiuser")] + public string Multiuser { get; set; } + [XmlAttribute(AttributeName = "myPlex")] + public string MyPlex { get; set; } + [XmlAttribute(AttributeName = "myPlexMappingState")] + public string MyPlexMappingState { get; set; } + [XmlAttribute(AttributeName = "myPlexSigninState")] + public string MyPlexSigninState { get; set; } + [XmlAttribute(AttributeName = "myPlexSubscription")] + public string MyPlexSubscription { get; set; } + [XmlAttribute(AttributeName = "myPlexUsername")] + public string MyPlexUsername { get; set; } + [XmlAttribute(AttributeName = "platform")] + public string Platform { get; set; } + [XmlAttribute(AttributeName = "platformVersion")] + public string PlatformVersion { get; set; } + [XmlAttribute(AttributeName = "requestParametersInCookie")] + public string RequestParametersInCookie { get; set; } + [XmlAttribute(AttributeName = "sync")] + public string Sync { get; set; } + [XmlAttribute(AttributeName = "transcoderActiveVideoSessions")] + public string TranscoderActiveVideoSessions { get; set; } + [XmlAttribute(AttributeName = "transcoderAudio")] + public string TranscoderAudio { get; set; } + [XmlAttribute(AttributeName = "transcoderLyrics")] + public string TranscoderLyrics { get; set; } + [XmlAttribute(AttributeName = "transcoderPhoto")] + public string TranscoderPhoto { get; set; } + [XmlAttribute(AttributeName = "transcoderSubtitles")] + public string TranscoderSubtitles { get; set; } + [XmlAttribute(AttributeName = "transcoderVideo")] + public string TranscoderVideo { get; set; } + [XmlAttribute(AttributeName = "transcoderVideoBitrates")] + public string TranscoderVideoBitrates { get; set; } + [XmlAttribute(AttributeName = "transcoderVideoQualities")] + public string TranscoderVideoQualities { get; set; } + [XmlAttribute(AttributeName = "transcoderVideoResolutions")] + public string TranscoderVideoResolutions { get; set; } + [XmlAttribute(AttributeName = "updatedAt")] + public string UpdatedAt { get; set; } + [XmlAttribute(AttributeName = "version")] + public string Version { get; set; } + } +} diff --git a/PlexRequests.Api.Models/Plex/PlexUserRequest.cs b/PlexRequests.Api.Models/Plex/PlexUserRequest.cs index a466740e4..ea45297ba 100644 --- a/PlexRequests.Api.Models/Plex/PlexUserRequest.cs +++ b/PlexRequests.Api.Models/Plex/PlexUserRequest.cs @@ -1,40 +1,40 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 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 PlexRequests.Api.Models.Plex -{ - public class PlexUserRequest - { - public UserRequest user { get; set; } - } - - public class UserRequest - { - public string login { get; set; } - public string password { get; set; } - } -} +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 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 PlexRequests.Api.Models.Plex +{ + public class PlexUserRequest + { + public UserRequest user { get; set; } + } + + public class UserRequest + { + public string login { get; set; } + public string password { get; set; } + } +} diff --git a/PlexRequests.Api.Models/Properties/AssemblyInfo.cs b/PlexRequests.Api.Models/Properties/AssemblyInfo.cs index 8115a2543..f226d6680 100644 --- a/PlexRequests.Api.Models/Properties/AssemblyInfo.cs +++ b/PlexRequests.Api.Models/Properties/AssemblyInfo.cs @@ -1,38 +1,38 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("PlexRequests.Api.Models")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("PlexRequests.Api.Models")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("cb37a5f8-6dfc-4554-99d3-a42b502e4591")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] - -[assembly: AssemblyInformationalVersionAttribute("1.0.0.0")] +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("PlexRequests.Api.Models")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PlexRequests.Api.Models")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("cb37a5f8-6dfc-4554-99d3-a42b502e4591")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] + +[assembly: AssemblyInformationalVersionAttribute("1.0.0.0")] diff --git a/PlexRequests.Api.Models/SickRage/SickRagePing.cs b/PlexRequests.Api.Models/SickRage/SickRagePing.cs index 46c8c94e7..1385c1ee8 100644 --- a/PlexRequests.Api.Models/SickRage/SickRagePing.cs +++ b/PlexRequests.Api.Models/SickRage/SickRagePing.cs @@ -1,37 +1,37 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: SickRagePing.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 PlexRequests.Api.Models.SickRage -{ - public class SickRagePingData - { - public int pid { get; set; } - } - - public class SickRagePing : SickRageBase - { - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: SickRagePing.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 PlexRequests.Api.Models.SickRage +{ + public class SickRagePingData + { + public int pid { get; set; } + } + + public class SickRagePing : SickRageBase + { + } } \ No newline at end of file diff --git a/PlexRequests.Api.Models/SickRage/SickRageSeasonList.cs b/PlexRequests.Api.Models/SickRage/SickRageSeasonList.cs index 7716204dc..80e561ca7 100644 --- a/PlexRequests.Api.Models/SickRage/SickRageSeasonList.cs +++ b/PlexRequests.Api.Models/SickRage/SickRageSeasonList.cs @@ -5,7 +5,7 @@ namespace PlexRequests.Api.Models.SickRage { public class SickRageSeasonList : SickRageBase { - [JsonIgnore] - public int[] Data => JsonConvertHelper.ParseObjectToArray(data); + [JsonIgnore] + public int[] Data => JsonConvertHelper.ParseObjectToArray(data); } } \ No newline at end of file diff --git a/PlexRequests.Api.Models/SickRage/SickRageShowInformation.cs b/PlexRequests.Api.Models/SickRage/SickRageShowInformation.cs index 511f692ab..295be41c3 100644 --- a/PlexRequests.Api.Models/SickRage/SickRageShowInformation.cs +++ b/PlexRequests.Api.Models/SickRage/SickRageShowInformation.cs @@ -1,82 +1,82 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: SickRageShowInformation.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; - -namespace PlexRequests.Api.Models.SickRage -{ - public class Cache - { - public int banner { get; set; } - public int poster { get; set; } - } - - public class QualityDetails - { - public List archive { get; set; } - public List initial { get; set; } - } - - public class SeasonList - { - } - - public class Data - { - public int air_by_date { get; set; } - public string airs { get; set; } - public int anime { get; set; } - public int archive_firstmatch { get; set; } - public Cache cache { get; set; } - public int dvdorder { get; set; } - public int flatten_folders { get; set; } - public List genre { get; set; } - public string imdbid { get; set; } - public int indexerid { get; set; } - public string language { get; set; } - public string location { get; set; } - public string network { get; set; } - public string next_ep_airdate { get; set; } - public int paused { get; set; } - public string quality { get; set; } - public QualityDetails quality_details { get; set; } - public List rls_ignore_words { get; set; } - public List rls_require_words { get; set; } - public int scene { get; set; } - public SeasonList season_list { get; set; } - public string show_name { get; set; } - public int sports { get; set; } - public string status { get; set; } - public int subtitles { get; set; } - public int tvdbid { get; set; } - } - - public class SickRageShowInformation : SickRageBase - { - } - +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: SickRageShowInformation.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; + +namespace PlexRequests.Api.Models.SickRage +{ + public class Cache + { + public int banner { get; set; } + public int poster { get; set; } + } + + public class QualityDetails + { + public List archive { get; set; } + public List initial { get; set; } + } + + public class SeasonList + { + } + + public class Data + { + public int air_by_date { get; set; } + public string airs { get; set; } + public int anime { get; set; } + public int archive_firstmatch { get; set; } + public Cache cache { get; set; } + public int dvdorder { get; set; } + public int flatten_folders { get; set; } + public List genre { get; set; } + public string imdbid { get; set; } + public int indexerid { get; set; } + public string language { get; set; } + public string location { get; set; } + public string network { get; set; } + public string next_ep_airdate { get; set; } + public int paused { get; set; } + public string quality { get; set; } + public QualityDetails quality_details { get; set; } + public List rls_ignore_words { get; set; } + public List rls_require_words { get; set; } + public int scene { get; set; } + public SeasonList season_list { get; set; } + public string show_name { get; set; } + public int sports { get; set; } + public string status { get; set; } + public int subtitles { get; set; } + public int tvdbid { get; set; } + } + + public class SickRageShowInformation : SickRageBase + { + } + } \ No newline at end of file diff --git a/PlexRequests.Api.Models/SickRage/SickRageStatus.cs b/PlexRequests.Api.Models/SickRage/SickRageStatus.cs index 2ea03632d..edeb03a21 100644 --- a/PlexRequests.Api.Models/SickRage/SickRageStatus.cs +++ b/PlexRequests.Api.Models/SickRage/SickRageStatus.cs @@ -1,35 +1,35 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: SickRageStatus.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 PlexRequests.Api.Models.SickRage -{ - public static class SickRageStatus - { - public const string Wanted = "wanted"; - public const string Skipped = "skipped"; - public const string Ignored = "Ignored"; - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: SickRageStatus.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 PlexRequests.Api.Models.SickRage +{ + public static class SickRageStatus + { + public const string Wanted = "wanted"; + public const string Skipped = "skipped"; + public const string Ignored = "Ignored"; + } } \ No newline at end of file diff --git a/PlexRequests.Api.Models/SickRage/SickRageTvAdd.cs b/PlexRequests.Api.Models/SickRage/SickRageTvAdd.cs index 15e2e3eae..e668b841c 100644 --- a/PlexRequests.Api.Models/SickRage/SickRageTvAdd.cs +++ b/PlexRequests.Api.Models/SickRage/SickRageTvAdd.cs @@ -1,38 +1,38 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: SickRageTvAdd.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 PlexRequests.Api.Models.SickRage -{ - public class SickRageTvAddData - { - public string name { get; set; } - } - - public class SickRageTvAdd : SickRageBase - { - } - +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: SickRageTvAdd.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 PlexRequests.Api.Models.SickRage +{ + public class SickRageTvAddData + { + public string name { get; set; } + } + + public class SickRageTvAdd : SickRageBase + { + } + } \ No newline at end of file diff --git a/PlexRequests.Api.Models/SickRage/SickrageShows.cs b/PlexRequests.Api.Models/SickRage/SickrageShows.cs index b33aeaf58..53131e56e 100644 --- a/PlexRequests.Api.Models/SickRage/SickrageShows.cs +++ b/PlexRequests.Api.Models/SickRage/SickrageShows.cs @@ -1,42 +1,42 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: SickrageShows.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; -using System.Collections.Generic; - -namespace PlexRequests.Api.Models.SickRage -{ - public class SickrageShows : SickRageBase> - { - - } - - public class Item - { - public int tvdbid { get; set; } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: SickrageShows.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; +using System.Collections.Generic; + +namespace PlexRequests.Api.Models.SickRage +{ + public class SickrageShows : SickRageBase> + { + + } + + public class Item + { + public int tvdbid { get; set; } + } } \ No newline at end of file diff --git a/PlexRequests.Api.Models/Sonarr/SonarrAllSeries.cs b/PlexRequests.Api.Models/Sonarr/SonarrAllSeries.cs index f788d18b7..608bb4f4a 100644 --- a/PlexRequests.Api.Models/Sonarr/SonarrAllSeries.cs +++ b/PlexRequests.Api.Models/Sonarr/SonarrAllSeries.cs @@ -1,69 +1,69 @@ -using System; -using System.Collections.Generic; - -namespace PlexRequests.Api.Models.Sonarr -{ - public class SonarrAllSeries - { - public List list { get; set; } - } - - public class Series - { - public string title { get; set; } - public List alternateTitles { get; set; } - public string sortTitle { get; set; } - public int seasonCount { get; set; } - public int totalEpisodeCount { get; set; } - public int episodeCount { get; set; } - public int episodeFileCount { get; set; } - public long sizeOnDisk { get; set; } - public string status { get; set; } - public string overview { get; set; } - public DateTime previousAiring { get; set; } - public string network { get; set; } - public List images { get; set; } - public List seasons { get; set; } - public int year { get; set; } - public string path { get; set; } - public int profileId { get; set; } - public bool seasonFolder { get; set; } - public bool monitored { get; set; } - public bool useSceneNumbering { get; set; } - public int runtime { get; set; } - public int tvdbId { get; set; } - public int tvRageId { get; set; } - public int tvMazeId { get; set; } - public DateTime firstAired { get; set; } - public DateTime lastInfoSync { get; set; } - public string seriesType { get; set; } - public string cleanTitle { get; set; } - public string imdbId { get; set; } - public string titleSlug { get; set; } - public string certification { get; set; } - public List genres { get; set; } - public List tags { get; set; } - public DateTime added { get; set; } - public Ratings ratings { get; set; } - public int qualityProfileId { get; set; } - public int id { get; set; } - } - - public class Ratings - { - public int votes { get; set; } - public float value { get; set; } - } - - public class Alternatetitle - { - public string title { get; set; } - public int seasonNumber { get; set; } - } - - public class Image - { - public string coverType { get; set; } - public string url { get; set; } - } -} +using System; +using System.Collections.Generic; + +namespace PlexRequests.Api.Models.Sonarr +{ + public class SonarrAllSeries + { + public List list { get; set; } + } + + public class Series + { + public string title { get; set; } + public List alternateTitles { get; set; } + public string sortTitle { get; set; } + public int seasonCount { get; set; } + public int totalEpisodeCount { get; set; } + public int episodeCount { get; set; } + public int episodeFileCount { get; set; } + public long sizeOnDisk { get; set; } + public string status { get; set; } + public string overview { get; set; } + public DateTime previousAiring { get; set; } + public string network { get; set; } + public List images { get; set; } + public List seasons { get; set; } + public int year { get; set; } + public string path { get; set; } + public int profileId { get; set; } + public bool seasonFolder { get; set; } + public bool monitored { get; set; } + public bool useSceneNumbering { get; set; } + public int runtime { get; set; } + public int tvdbId { get; set; } + public int tvRageId { get; set; } + public int tvMazeId { get; set; } + public DateTime firstAired { get; set; } + public DateTime lastInfoSync { get; set; } + public string seriesType { get; set; } + public string cleanTitle { get; set; } + public string imdbId { get; set; } + public string titleSlug { get; set; } + public string certification { get; set; } + public List genres { get; set; } + public List tags { get; set; } + public DateTime added { get; set; } + public Ratings ratings { get; set; } + public int qualityProfileId { get; set; } + public int id { get; set; } + } + + public class Ratings + { + public int votes { get; set; } + public float value { get; set; } + } + + public class Alternatetitle + { + public string title { get; set; } + public int seasonNumber { get; set; } + } + + public class Image + { + public string coverType { get; set; } + public string url { get; set; } + } +} diff --git a/PlexRequests.Api.Models/Sonarr/SonarrProfile.cs b/PlexRequests.Api.Models/Sonarr/SonarrProfile.cs index 2aee359bb..b95fe32fe 100644 --- a/PlexRequests.Api.Models/Sonarr/SonarrProfile.cs +++ b/PlexRequests.Api.Models/Sonarr/SonarrProfile.cs @@ -1,57 +1,57 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: SonarrProfile.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; - -namespace PlexRequests.Api.Models.Sonarr -{ - public class Cutoff - { - public int id { get; set; } - public string name { get; set; } - } - - public class Quality - { - public int id { get; set; } - public string name { get; set; } - } - - public class Item - { - public Quality quality { get; set; } - public bool allowed { get; set; } - } - - public class SonarrProfile - { - public string name { get; set; } - public Cutoff cutoff { get; set; } - public List items { get; set; } - public int id { get; set; } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: SonarrProfile.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; + +namespace PlexRequests.Api.Models.Sonarr +{ + public class Cutoff + { + public int id { get; set; } + public string name { get; set; } + } + + public class Quality + { + public int id { get; set; } + public string name { get; set; } + } + + public class Item + { + public Quality quality { get; set; } + public bool allowed { get; set; } + } + + public class SonarrProfile + { + public string name { get; set; } + public Cutoff cutoff { get; set; } + public List items { get; set; } + public int id { get; set; } + } } \ No newline at end of file diff --git a/PlexRequests.Api.Models/Sonarr/SystemStatus.cs b/PlexRequests.Api.Models/Sonarr/SystemStatus.cs index 19d822805..8dc3c0f57 100644 --- a/PlexRequests.Api.Models/Sonarr/SystemStatus.cs +++ b/PlexRequests.Api.Models/Sonarr/SystemStatus.cs @@ -1,51 +1,51 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: SystemStatus.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 PlexRequests.Api.Models.Sonarr -{ - public class SystemStatus - { - public string version { get; set; } - public string buildTime { get; set; } - public bool isDebug { get; set; } - public bool isProduction { get; set; } - public bool isAdmin { get; set; } - public bool isUserInteractive { get; set; } - public string startupPath { get; set; } - public string appData { get; set; } - public string osVersion { get; set; } - public bool isMonoRuntime { get; set; } - public bool isMono { get; set; } - public bool isLinux { get; set; } - public bool isOsx { get; set; } - public bool isWindows { get; set; } - public string branch { get; set; } - public string authentication { get; set; } - public string sqliteVersion { get; set; } - public string urlBase { get; set; } - public string runtimeVersion { get; set; } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: SystemStatus.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 PlexRequests.Api.Models.Sonarr +{ + public class SystemStatus + { + public string version { get; set; } + public string buildTime { get; set; } + public bool isDebug { get; set; } + public bool isProduction { get; set; } + public bool isAdmin { get; set; } + public bool isUserInteractive { get; set; } + public string startupPath { get; set; } + public string appData { get; set; } + public string osVersion { get; set; } + public bool isMonoRuntime { get; set; } + public bool isMono { get; set; } + public bool isLinux { get; set; } + public bool isOsx { get; set; } + public bool isWindows { get; set; } + public string branch { get; set; } + public string authentication { get; set; } + public string sqliteVersion { get; set; } + public string urlBase { get; set; } + public string runtimeVersion { get; set; } + } } \ No newline at end of file diff --git a/PlexRequests.Api.Models/Tv/Authentication.cs b/PlexRequests.Api.Models/Tv/Authentication.cs index ca2cb1d62..ae427ff45 100644 --- a/PlexRequests.Api.Models/Tv/Authentication.cs +++ b/PlexRequests.Api.Models/Tv/Authentication.cs @@ -1,33 +1,33 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: Authentication.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 PlexRequests.Api.Models.Tv -{ - public class Authentication - { - public string token { get; set; } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: Authentication.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 PlexRequests.Api.Models.Tv +{ + public class Authentication + { + public string token { get; set; } + } } \ No newline at end of file diff --git a/PlexRequests.Api.Models/Tv/TvSearchResult.cs b/PlexRequests.Api.Models/Tv/TvSearchResult.cs index a8bd9d35f..a97b6834b 100644 --- a/PlexRequests.Api.Models/Tv/TvSearchResult.cs +++ b/PlexRequests.Api.Models/Tv/TvSearchResult.cs @@ -1,68 +1,68 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: TvSearchResult.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; - -namespace PlexRequests.Api.Models.Tv -{ - public class TvShowSearchResult - { - public int id { get; set; } - public int airedSeason { get; set; } - public int airedEpisodeNumber { get; set; } - public string episodeName { get; set; } - public string firstAired { get; set; } - public string guestStars { get; set; } - public string director { get; set; } - public List writers { get; set; } - public string overview { get; set; } - public string productionCode { get; set; } - public string showUrl { get; set; } - public int lastUpdated { get; set; } - public string dvdDiscid { get; set; } - public int dvdSeason { get; set; } - public int dvdEpisodeNumber { get; set; } - public int dvdChapter { get; set; } - public int absoluteNumber { get; set; } - public string filename { get; set; } - public string seriesId { get; set; } - public string lastUpdatedBy { get; set; } - public int airsAfterSeason { get; set; } - public int airsBeforeSeason { get; set; } - public int airsBeforeEpisode { get; set; } - public string thumbAuthor { get; set; } - public string thumbAdded { get; set; } - public string thumbWidth { get; set; } - public string thumbHeight { get; set; } - public string imdbId { get; set; } - public int siteRating { get; set; } - } - - public class TvSearchResult - { - public List data { get; set; } - } -} +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: TvSearchResult.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; + +namespace PlexRequests.Api.Models.Tv +{ + public class TvShowSearchResult + { + public int id { get; set; } + public int airedSeason { get; set; } + public int airedEpisodeNumber { get; set; } + public string episodeName { get; set; } + public string firstAired { get; set; } + public string guestStars { get; set; } + public string director { get; set; } + public List writers { get; set; } + public string overview { get; set; } + public string productionCode { get; set; } + public string showUrl { get; set; } + public int lastUpdated { get; set; } + public string dvdDiscid { get; set; } + public int dvdSeason { get; set; } + public int dvdEpisodeNumber { get; set; } + public int dvdChapter { get; set; } + public int absoluteNumber { get; set; } + public string filename { get; set; } + public string seriesId { get; set; } + public string lastUpdatedBy { get; set; } + public int airsAfterSeason { get; set; } + public int airsBeforeSeason { get; set; } + public int airsBeforeEpisode { get; set; } + public string thumbAuthor { get; set; } + public string thumbAdded { get; set; } + public string thumbWidth { get; set; } + public string thumbHeight { get; set; } + public string imdbId { get; set; } + public int siteRating { get; set; } + } + + public class TvSearchResult + { + public List data { get; set; } + } +} diff --git a/PlexRequests.Api.Models/Tv/TvShow.cs b/PlexRequests.Api.Models/Tv/TvShow.cs index 84cb69fb9..d11024a31 100644 --- a/PlexRequests.Api.Models/Tv/TvShow.cs +++ b/PlexRequests.Api.Models/Tv/TvShow.cs @@ -1,61 +1,61 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: TvShow.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; - -namespace PlexRequests.Api.Models.Tv -{ - public class TvShow - { - public int id { get; set; } - public string seriesName { get; set; } - public List aliases { get; set; } - public string banner { get; set; } - public string seriesId { get; set; } - public string status { get; set; } - public string firstAired { get; set; } - public string network { get; set; } - public string networkId { get; set; } - public string runtime { get; set; } - public List genre { get; set; } - public string overview { get; set; } - public int lastUpdated { get; set; } - public string airsDayOfWeek { get; set; } - public string airsTime { get; set; } - public string rating { get; set; } - public string imdbId { get; set; } - public string zap2itId { get; set; } - public string added { get; set; } - public int addedBy { get; set; } - public int siteRating { get; set; } - - } - - public class TvShowInformation - { - public TvShow data { get; set; } - } -} +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: TvShow.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; + +namespace PlexRequests.Api.Models.Tv +{ + public class TvShow + { + public int id { get; set; } + public string seriesName { get; set; } + public List aliases { get; set; } + public string banner { get; set; } + public string seriesId { get; set; } + public string status { get; set; } + public string firstAired { get; set; } + public string network { get; set; } + public string networkId { get; set; } + public string runtime { get; set; } + public List genre { get; set; } + public string overview { get; set; } + public int lastUpdated { get; set; } + public string airsDayOfWeek { get; set; } + public string airsTime { get; set; } + public string rating { get; set; } + public string imdbId { get; set; } + public string zap2itId { get; set; } + public string added { get; set; } + public int addedBy { get; set; } + public int siteRating { get; set; } + + } + + public class TvShowInformation + { + public TvShow data { get; set; } + } +} diff --git a/PlexRequests.Api.Models/Tv/TvShowImages.cs b/PlexRequests.Api.Models/Tv/TvShowImages.cs index 6d9d4387b..7100657c3 100644 --- a/PlexRequests.Api.Models/Tv/TvShowImages.cs +++ b/PlexRequests.Api.Models/Tv/TvShowImages.cs @@ -1,54 +1,54 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: TvShowImages.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; - -namespace PlexRequests.Api.Models.Tv -{ - public class RatingsInfo - { - public double average { get; set; } - } - - public class Datum - { - public int id { get; set; } - public string keyType { get; set; } - public string subKey { get; set; } - public string fileName { get; set; } - public string resolution { get; set; } - public RatingsInfo ratingsInfo { get; set; } - public string thumbnail { get; set; } - } - - public class TvShowImages - { - public List data { get; set; } - public object errors { get; set; } - } - +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: TvShowImages.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; + +namespace PlexRequests.Api.Models.Tv +{ + public class RatingsInfo + { + public double average { get; set; } + } + + public class Datum + { + public int id { get; set; } + public string keyType { get; set; } + public string subKey { get; set; } + public string fileName { get; set; } + public string resolution { get; set; } + public RatingsInfo ratingsInfo { get; set; } + public string thumbnail { get; set; } + } + + public class TvShowImages + { + public List data { get; set; } + public object errors { get; set; } + } + } \ No newline at end of file diff --git a/PlexRequests.Api/ApiRequest.cs b/PlexRequests.Api/ApiRequest.cs index 8cb023ea6..8bf1a2721 100644 --- a/PlexRequests.Api/ApiRequest.cs +++ b/PlexRequests.Api/ApiRequest.cs @@ -104,8 +104,7 @@ namespace PlexRequests.Api } var result = DeserializeXml(response.Content); - return result; - } + return result;} public T ExecuteJson(IRestRequest request, Uri baseUri) where T : new() { diff --git a/PlexRequests.Api/CouchPotatoApi.cs b/PlexRequests.Api/CouchPotatoApi.cs index e4382ff22..9523d7284 100644 --- a/PlexRequests.Api/CouchPotatoApi.cs +++ b/PlexRequests.Api/CouchPotatoApi.cs @@ -65,9 +65,7 @@ namespace PlexRequests.Api var obj = RetryHandler.Execute(() => Api.ExecuteJson(request, baseUrl), (exception, timespan) => Log.Error(exception, "Exception when calling AddMovie for CP, Retrying {0}", timespan), new[] { - TimeSpan.FromSeconds (2), - TimeSpan.FromSeconds(5), - TimeSpan.FromSeconds(10)}); + TimeSpan.FromSeconds (2)}); if (obj.Count > 0) diff --git a/PlexRequests.Api/HeadphonesApi.cs b/PlexRequests.Api/HeadphonesApi.cs index 94c29f126..4b6c08a80 100644 --- a/PlexRequests.Api/HeadphonesApi.cs +++ b/PlexRequests.Api/HeadphonesApi.cs @@ -1,204 +1,204 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: HeadphonesApi.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; -using System.Collections.Generic; -using System.Threading.Tasks; - -using Newtonsoft.Json; - -using NLog; - -using PlexRequests.Api.Interfaces; -using PlexRequests.Api.Models.Music; -using PlexRequests.Helpers; - -using RestSharp; - -namespace PlexRequests.Api -{ - public class HeadphonesApi : IHeadphonesApi - { - public HeadphonesApi() - { - Api = new ApiRequest(); - } - private ApiRequest Api { get; } - private static readonly Logger Log = LogManager.GetCurrentClassLogger(); - - public async Task AddAlbum(string apiKey, Uri baseUrl, string albumId) - { - Log.Trace("Adding album: {0}", albumId); - var request = new RestRequest - { - Resource = "/api?cmd=addAlbum&id={albumId}", - Method = Method.GET - }; - - request.AddQueryParameter("apikey", apiKey); - request.AddUrlSegment("albumId", albumId); - - try - { - var result = await Task.Run(() => Api.Execute(request, baseUrl)).ConfigureAwait(false); - Log.Trace("Add Album Result: {0}", result.DumpJson()); - - var albumResult = result.Content.Equals("OK", StringComparison.CurrentCultureIgnoreCase); - Log.Info("Album add result {0}", albumResult); - - return albumResult; - } - catch (Exception jse) - { - Log.Error(jse); - return false; // If there is no matching result we do not get returned a JSON string, it just returns "false". - } - } - public async Task> GetIndex(string apiKey, Uri baseUrl) - { - var request = new RestRequest - { - Resource = "/api", - Method = Method.GET - }; - - request.AddQueryParameter("apikey", apiKey); - request.AddQueryParameter("cmd", "getIndex"); - - try - { - var result = await Task.Run(() => Api.ExecuteJson>(request, baseUrl)).ConfigureAwait(false); - - return result; - } - catch (Exception jse) - { - Log.Error(jse); - return new List(); - } - } - public async Task AddArtist(string apiKey, Uri baseUrl, string artistId) - { - Log.Trace("Adding Artist: {0}", artistId); - var request = new RestRequest - { - Resource = "/api", - Method = Method.GET - }; - - request.AddQueryParameter("apikey", apiKey); - request.AddQueryParameter("cmd", "addArtist"); - request.AddQueryParameter("id", artistId); - - try - { - var result = await Task.Run(() => Api.Execute(request, baseUrl)).ConfigureAwait(false); - Log.Info("Add Artist Result: {0}", result.Content); - Log.Trace("Add Artist Result: {0}", result.DumpJson()); - return result.Content.Equals("OK", StringComparison.CurrentCultureIgnoreCase); - } - catch (JsonSerializationException jse) - { - Log.Error(jse); - return false; // If there is no matching result we do not get returned a JSON string, it just returns "false". - } - } - public async Task QueueAlbum(string apiKey, Uri baseUrl, string albumId) - { - Log.Trace("Queing album: {0}", albumId); - var request = new RestRequest - { - Resource = "/api?cmd=queueAlbum&id={albumId}", - Method = Method.GET - }; - - request.AddQueryParameter("apikey", apiKey); - request.AddUrlSegment("albumId", albumId); - - try - { - var result = await Task.Run(() => Api.Execute(request, baseUrl)).ConfigureAwait(false); - Log.Info("Queue Result: {0}", result.Content); - Log.Trace("Queue Result: {0}", result.DumpJson()); - return result.Content.Equals("OK", StringComparison.CurrentCultureIgnoreCase); - } - catch (JsonSerializationException jse) - { - Log.Error(jse); - return false; // If there is no matching result we do not get returned a JSON string, it just returns "false". - } - } - - public async Task RefreshArtist(string apiKey, Uri baseUrl, string artistId) - { - Log.Trace("Refreshing artist: {0}", artistId); - var request = new RestRequest - { - Resource = "/api", - Method = Method.GET - }; - - request.AddQueryParameter("apikey", apiKey); - request.AddQueryParameter("cmd", "queueAlbum"); - request.AddQueryParameter("id", artistId); - - try - { - var result = await Task.Run(() => Api.Execute(request, baseUrl)).ConfigureAwait(false); - Log.Info("Artist refresh Result: {0}", result.Content); - Log.Trace("Artist refresh Result: {0}", result.DumpJson()); - return result.Content.Equals("OK", StringComparison.CurrentCultureIgnoreCase); - } - catch (JsonSerializationException jse) - { - Log.Error(jse); - return false; // If there is no matching result we do not get returned a JSON string, it just returns "false". - } - } - - public HeadphonesVersion GetVersion(string apiKey, Uri baseUrl) - { - var request = new RestRequest - { - Resource = "/api", - Method = Method.GET - }; - - request.AddQueryParameter("apikey", apiKey); - request.AddQueryParameter("cmd", "getVersion"); - - try - { - return Api.ExecuteJson(request, baseUrl); - } - catch (JsonSerializationException jse) - { - Log.Error(jse); - return new HeadphonesVersion(); // If there is no matching result we do not get returned a JSON string, it just returns "false". - } - } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: HeadphonesApi.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; +using System.Collections.Generic; +using System.Threading.Tasks; + +using Newtonsoft.Json; + +using NLog; + +using PlexRequests.Api.Interfaces; +using PlexRequests.Api.Models.Music; +using PlexRequests.Helpers; + +using RestSharp; + +namespace PlexRequests.Api +{ + public class HeadphonesApi : IHeadphonesApi + { + public HeadphonesApi() + { + Api = new ApiRequest(); + } + private ApiRequest Api { get; } + private static readonly Logger Log = LogManager.GetCurrentClassLogger(); + + public async Task AddAlbum(string apiKey, Uri baseUrl, string albumId) + { + Log.Trace("Adding album: {0}", albumId); + var request = new RestRequest + { + Resource = "/api?cmd=addAlbum&id={albumId}", + Method = Method.GET + }; + + request.AddQueryParameter("apikey", apiKey); + request.AddUrlSegment("albumId", albumId); + + try + { + var result = await Task.Run(() => Api.Execute(request, baseUrl)).ConfigureAwait(false); + Log.Trace("Add Album Result: {0}", result.DumpJson()); + + var albumResult = result.Content.Equals("OK", StringComparison.CurrentCultureIgnoreCase); + Log.Info("Album add result {0}", albumResult); + + return albumResult; + } + catch (Exception jse) + { + Log.Error(jse); + return false; // If there is no matching result we do not get returned a JSON string, it just returns "false". + } + } + public async Task> GetIndex(string apiKey, Uri baseUrl) + { + var request = new RestRequest + { + Resource = "/api", + Method = Method.GET + }; + + request.AddQueryParameter("apikey", apiKey); + request.AddQueryParameter("cmd", "getIndex"); + + try + { + var result = await Task.Run(() => Api.ExecuteJson>(request, baseUrl)).ConfigureAwait(false); + + return result; + } + catch (Exception jse) + { + Log.Error(jse); + return new List(); + } + } + public async Task AddArtist(string apiKey, Uri baseUrl, string artistId) + { + Log.Trace("Adding Artist: {0}", artistId); + var request = new RestRequest + { + Resource = "/api", + Method = Method.GET + }; + + request.AddQueryParameter("apikey", apiKey); + request.AddQueryParameter("cmd", "addArtist"); + request.AddQueryParameter("id", artistId); + + try + { + var result = await Task.Run(() => Api.Execute(request, baseUrl)).ConfigureAwait(false); + Log.Info("Add Artist Result: {0}", result.Content); + Log.Trace("Add Artist Result: {0}", result.DumpJson()); + return result.Content.Equals("OK", StringComparison.CurrentCultureIgnoreCase); + } + catch (JsonSerializationException jse) + { + Log.Error(jse); + return false; // If there is no matching result we do not get returned a JSON string, it just returns "false". + } + } + public async Task QueueAlbum(string apiKey, Uri baseUrl, string albumId) + { + Log.Trace("Queing album: {0}", albumId); + var request = new RestRequest + { + Resource = "/api?cmd=queueAlbum&id={albumId}", + Method = Method.GET + }; + + request.AddQueryParameter("apikey", apiKey); + request.AddUrlSegment("albumId", albumId); + + try + { + var result = await Task.Run(() => Api.Execute(request, baseUrl)).ConfigureAwait(false); + Log.Info("Queue Result: {0}", result.Content); + Log.Trace("Queue Result: {0}", result.DumpJson()); + return result.Content.Equals("OK", StringComparison.CurrentCultureIgnoreCase); + } + catch (JsonSerializationException jse) + { + Log.Error(jse); + return false; // If there is no matching result we do not get returned a JSON string, it just returns "false". + } + } + + public async Task RefreshArtist(string apiKey, Uri baseUrl, string artistId) + { + Log.Trace("Refreshing artist: {0}", artistId); + var request = new RestRequest + { + Resource = "/api", + Method = Method.GET + }; + + request.AddQueryParameter("apikey", apiKey); + request.AddQueryParameter("cmd", "queueAlbum"); + request.AddQueryParameter("id", artistId); + + try + { + var result = await Task.Run(() => Api.Execute(request, baseUrl)).ConfigureAwait(false); + Log.Info("Artist refresh Result: {0}", result.Content); + Log.Trace("Artist refresh Result: {0}", result.DumpJson()); + return result.Content.Equals("OK", StringComparison.CurrentCultureIgnoreCase); + } + catch (JsonSerializationException jse) + { + Log.Error(jse); + return false; // If there is no matching result we do not get returned a JSON string, it just returns "false". + } + } + + public HeadphonesVersion GetVersion(string apiKey, Uri baseUrl) + { + var request = new RestRequest + { + Resource = "/api", + Method = Method.GET + }; + + request.AddQueryParameter("apikey", apiKey); + request.AddQueryParameter("cmd", "getVersion"); + + try + { + return Api.ExecuteJson(request, baseUrl); + } + catch (JsonSerializationException jse) + { + Log.Error(jse); + return new HeadphonesVersion(); // If there is no matching result we do not get returned a JSON string, it just returns "false". + } + } + } } \ No newline at end of file diff --git a/PlexRequests.Api/MovieBase.cs b/PlexRequests.Api/MovieBase.cs index d3d69fbd1..8a62e0209 100644 --- a/PlexRequests.Api/MovieBase.cs +++ b/PlexRequests.Api/MovieBase.cs @@ -1,36 +1,36 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: TvBase.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 PlexRequests.Helpers; - -namespace PlexRequests.Api -{ - public abstract class MovieBase - { - private static readonly string Encrypted = "0T3QNSseexLO7n7UPiJvl70Y+KKnvbeTlsusl7Kwq0hPH0BHOuFNGwksNCjkwqWedyDdI/MJeUR4wtL4bIl0Z+//uHXEaYM/4H2pjeLbH5EWdUe5TTj1AhaIR5PQweamvcienRyFD/3YPCC/+qL5mHkKXBkPumMod3Zb/4yN0Ik="; - protected string ApiKey = StringCipher.Decrypt(Encrypted, "ApiKey"); - } -} +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: TvBase.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 PlexRequests.Helpers; + +namespace PlexRequests.Api +{ + public abstract class MovieBase + { + private static readonly string Encrypted = "0T3QNSseexLO7n7UPiJvl70Y+KKnvbeTlsusl7Kwq0hPH0BHOuFNGwksNCjkwqWedyDdI/MJeUR4wtL4bIl0Z+//uHXEaYM/4H2pjeLbH5EWdUe5TTj1AhaIR5PQweamvcienRyFD/3YPCC/+qL5mHkKXBkPumMod3Zb/4yN0Ik="; + protected string ApiKey = StringCipher.Decrypt(Encrypted, "ApiKey"); + } +} diff --git a/PlexRequests.Api/MusicBrainzApi.cs b/PlexRequests.Api/MusicBrainzApi.cs index c810df6c3..b9c581986 100644 --- a/PlexRequests.Api/MusicBrainzApi.cs +++ b/PlexRequests.Api/MusicBrainzApi.cs @@ -1,116 +1,116 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: MusicBrainzApi.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; - -using Newtonsoft.Json; - -using NLog; - -using PlexRequests.Api.Interfaces; -using PlexRequests.Api.Models.Music; - -using RestSharp; - -namespace PlexRequests.Api -{ - public class MusicBrainzApi : IMusicBrainzApi - { - public MusicBrainzApi() - { - Api = new ApiRequest(); - } - private ApiRequest Api { get; } - private static readonly Logger Log = LogManager.GetCurrentClassLogger(); - private readonly Uri BaseUri = new Uri("http://musicbrainz.org/ws/2/"); - - public MusicBrainzSearchResults SearchAlbum(string searchTerm) - { - Log.Trace("Searching for album: {0}", searchTerm); - var request = new RestRequest - { - Resource = "release/?query={searchTerm}&fmt=json", - Method = Method.GET - }; - request.AddUrlSegment("searchTerm", searchTerm); - - try - { - return Api.ExecuteJson(request, BaseUri); - } - catch (JsonSerializationException jse) - { - Log.Warn(jse); - return new MusicBrainzSearchResults(); // If there is no matching result we do not get returned a JSON string, it just returns "false". - } - } - - public MusicBrainzReleaseInfo GetAlbum(string releaseId) - { - Log.Trace("Getting album: {0}", releaseId); - var request = new RestRequest - { - Resource = "release/{albumId}", - Method = Method.GET - }; - request.AddUrlSegment("albumId", releaseId); - request.AddQueryParameter("fmt", "json"); - request.AddQueryParameter("inc", "artists"); - - try - { - return Api.ExecuteJson(request, BaseUri); - } - catch (JsonSerializationException jse) - { - Log.Warn(jse); - return new MusicBrainzReleaseInfo(); // If there is no matching result we do not get returned a JSON string, it just returns "false". - } - } - - public MusicBrainzCoverArt GetCoverArt(string releaseId) - { - Log.Trace("Getting cover art for release: {0}", releaseId); - var request = new RestRequest - { - Resource = "release/{releaseId}", - Method = Method.GET - }; - request.AddUrlSegment("releaseId", releaseId); - - try - { - return Api.Execute(request, new Uri("http://coverartarchive.org/")); - } - catch (Exception e) - { - Log.Warn(e); - return new MusicBrainzCoverArt(); // If there is no matching result we do not get returned a JSON string, it just returns "false". - } - } - - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: MusicBrainzApi.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; + +using Newtonsoft.Json; + +using NLog; + +using PlexRequests.Api.Interfaces; +using PlexRequests.Api.Models.Music; + +using RestSharp; + +namespace PlexRequests.Api +{ + public class MusicBrainzApi : IMusicBrainzApi + { + public MusicBrainzApi() + { + Api = new ApiRequest(); + } + private ApiRequest Api { get; } + private static readonly Logger Log = LogManager.GetCurrentClassLogger(); + private readonly Uri BaseUri = new Uri("http://musicbrainz.org/ws/2/"); + + public MusicBrainzSearchResults SearchAlbum(string searchTerm) + { + Log.Trace("Searching for album: {0}", searchTerm); + var request = new RestRequest + { + Resource = "release/?query={searchTerm}&fmt=json", + Method = Method.GET + }; + request.AddUrlSegment("searchTerm", searchTerm); + + try + { + return Api.ExecuteJson(request, BaseUri); + } + catch (JsonSerializationException jse) + { + Log.Warn(jse); + return new MusicBrainzSearchResults(); // If there is no matching result we do not get returned a JSON string, it just returns "false". + } + } + + public MusicBrainzReleaseInfo GetAlbum(string releaseId) + { + Log.Trace("Getting album: {0}", releaseId); + var request = new RestRequest + { + Resource = "release/{albumId}", + Method = Method.GET + }; + request.AddUrlSegment("albumId", releaseId); + request.AddQueryParameter("fmt", "json"); + request.AddQueryParameter("inc", "artists"); + + try + { + return Api.ExecuteJson(request, BaseUri); + } + catch (JsonSerializationException jse) + { + Log.Warn(jse); + return new MusicBrainzReleaseInfo(); // If there is no matching result we do not get returned a JSON string, it just returns "false". + } + } + + public MusicBrainzCoverArt GetCoverArt(string releaseId) + { + Log.Trace("Getting cover art for release: {0}", releaseId); + var request = new RestRequest + { + Resource = "release/{releaseId}", + Method = Method.GET + }; + request.AddUrlSegment("releaseId", releaseId); + + try + { + return Api.Execute(request, new Uri("http://coverartarchive.org/")); + } + catch (Exception e) + { + Log.Warn(e); + return new MusicBrainzCoverArt(); // If there is no matching result we do not get returned a JSON string, it just returns "false". + } + } + + } } \ No newline at end of file diff --git a/PlexRequests.Api/Properties/AssemblyInfo.cs b/PlexRequests.Api/Properties/AssemblyInfo.cs index e09af95eb..9b93a138e 100644 --- a/PlexRequests.Api/Properties/AssemblyInfo.cs +++ b/PlexRequests.Api/Properties/AssemblyInfo.cs @@ -1,37 +1,37 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("PlexRequests.Api")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("PlexRequests.Api")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("8cb8d235-2674-442d-9c6a-35fcaeeb160d")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] -[assembly: AssemblyInformationalVersionAttribute("1.0.0.0")] +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("PlexRequests.Api")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PlexRequests.Api")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("8cb8d235-2674-442d-9c6a-35fcaeeb160d")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyInformationalVersionAttribute("1.0.0.0")] diff --git a/PlexRequests.Api/PushbulletApi.cs b/PlexRequests.Api/PushbulletApi.cs index 1e399e048..fe9dbf46e 100644 --- a/PlexRequests.Api/PushbulletApi.cs +++ b/PlexRequests.Api/PushbulletApi.cs @@ -1,64 +1,64 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: PlexApi.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; -using System.Threading.Tasks; - -using PlexRequests.Api.Interfaces; -using PlexRequests.Api.Models.Notifications; - -using RestSharp; - -namespace PlexRequests.Api -{ - public class PushbulletApi : IPushbulletApi - { - public async Task PushAsync(string accessToken, string title, string message, string deviceIdentifier = default(string)) - { - var request = new RestRequest - { - Method = Method.POST, - - }; - - request.AddHeader("Access-Token", accessToken); - request.AddHeader("Content-Type", "application/json"); - - var push = new PushbulletPush { title = title, body = message, type = "note"}; - - if (!string.IsNullOrEmpty(deviceIdentifier)) - { - push.device_iden = deviceIdentifier; - } - - request.AddJsonBody(push); - - var api = new ApiRequest(); - return await Task.Run(() => api.ExecuteJson(request, new Uri("https://api.pushbullet.com/v2/pushes"))); - } - } -} - +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: PlexApi.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; +using System.Threading.Tasks; + +using PlexRequests.Api.Interfaces; +using PlexRequests.Api.Models.Notifications; + +using RestSharp; + +namespace PlexRequests.Api +{ + public class PushbulletApi : IPushbulletApi + { + public async Task PushAsync(string accessToken, string title, string message, string deviceIdentifier = default(string)) + { + var request = new RestRequest + { + Method = Method.POST, + + }; + + request.AddHeader("Access-Token", accessToken); + request.AddHeader("Content-Type", "application/json"); + + var push = new PushbulletPush { title = title, body = message, type = "note"}; + + if (!string.IsNullOrEmpty(deviceIdentifier)) + { + push.device_iden = deviceIdentifier; + } + + request.AddJsonBody(push); + + var api = new ApiRequest(); + return await Task.Run(() => api.ExecuteJson(request, new Uri("https://api.pushbullet.com/v2/pushes"))); + } + } +} + diff --git a/PlexRequests.Api/PushoverApi.cs b/PlexRequests.Api/PushoverApi.cs index 6d109ca9b..068e5b800 100644 --- a/PlexRequests.Api/PushoverApi.cs +++ b/PlexRequests.Api/PushoverApi.cs @@ -1,57 +1,57 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: PlexApi.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; -using System.Threading.Tasks; - -using PlexRequests.Api.Interfaces; -using PlexRequests.Api.Models.Notifications; - -using RestSharp; - -namespace PlexRequests.Api -{ - public class PushoverApi : IPushoverApi - { - public async Task PushAsync(string accessToken, string message, string userToken) - { - var request = new RestRequest - { - Method = Method.POST, - Resource = "messages.json?token={token}&user={user}&message={message}" - }; - - request.AddUrlSegment("token", accessToken); - request.AddUrlSegment("message", message); - request.AddUrlSegment("user", userToken); - - - var api = new ApiRequest(); - return await Task.Run(() => api.ExecuteJson(request, new Uri("https://api.pushover.net/1"))); - } - } -} - +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: PlexApi.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; +using System.Threading.Tasks; + +using PlexRequests.Api.Interfaces; +using PlexRequests.Api.Models.Notifications; + +using RestSharp; + +namespace PlexRequests.Api +{ + public class PushoverApi : IPushoverApi + { + public async Task PushAsync(string accessToken, string message, string userToken) + { + var request = new RestRequest + { + Method = Method.POST, + Resource = "messages.json?token={token}&user={user}&message={message}" + }; + + request.AddUrlSegment("token", accessToken); + request.AddUrlSegment("message", message); + request.AddUrlSegment("user", userToken); + + + var api = new ApiRequest(); + return await Task.Run(() => api.ExecuteJson(request, new Uri("https://api.pushover.net/1"))); + } + } +} + diff --git a/PlexRequests.Api/RetryHandler.cs b/PlexRequests.Api/RetryHandler.cs index d3ffb1912..f385b6c5c 100644 --- a/PlexRequests.Api/RetryHandler.cs +++ b/PlexRequests.Api/RetryHandler.cs @@ -33,7 +33,7 @@ namespace PlexRequests.Api { public static class RetryHandler { - private static readonly TimeSpan[] DefaultRetryTime = { TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(10) }; + private static readonly TimeSpan[] DefaultRetryTime = { TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5) }; public static T Execute(Func action, TimeSpan[] timeSpan = null) { diff --git a/PlexRequests.Api/SonarrApi.cs b/PlexRequests.Api/SonarrApi.cs index 961f04ea2..10811f10f 100644 --- a/PlexRequests.Api/SonarrApi.cs +++ b/PlexRequests.Api/SonarrApi.cs @@ -117,8 +117,7 @@ namespace PlexRequests.Api try { var policy = RetryHandler.RetryAndWaitPolicy((exception, timespan) => Log.Error(exception, "Exception when calling AddSeries for Sonarr, Retrying {0}", timespan), new TimeSpan[] { - TimeSpan.FromSeconds (1), - TimeSpan.FromSeconds(2), + TimeSpan.FromSeconds (2) }); result = policy.Execute(() => Api.ExecuteJson(request, baseUrl)); @@ -186,8 +185,7 @@ namespace PlexRequests.Api try { var policy = RetryHandler.RetryAndWaitPolicy((exception, timespan) => Log.Error(exception, "Exception when calling AddSeries for Sonarr, Retrying {0}", timespan), new TimeSpan[] { - TimeSpan.FromSeconds (1), - TimeSpan.FromSeconds(2), + TimeSpan.FromSeconds (2) }); result = policy.Execute(() => Api.ExecuteJson(request, baseUrl)); @@ -228,8 +226,8 @@ namespace PlexRequests.Api { var policy = RetryHandler.RetryAndWaitPolicy((exception, timespan) => Log.Error(exception, "Exception when calling GetSeries for Sonarr, Retrying {0}", timespan), new TimeSpan[] { TimeSpan.FromSeconds (5), - TimeSpan.FromSeconds(10), - TimeSpan.FromSeconds(30) + TimeSpan.FromSeconds(5), + TimeSpan.FromSeconds(5) }); return policy.Execute(() => Api.ExecuteJson>(request, baseUrl)); diff --git a/PlexRequests.Api/TheTvDbApi.cs b/PlexRequests.Api/TheTvDbApi.cs index 2ac7734f7..057558eef 100644 --- a/PlexRequests.Api/TheTvDbApi.cs +++ b/PlexRequests.Api/TheTvDbApi.cs @@ -1,144 +1,144 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: TheTvDbApi.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; - -using PlexRequests.Api.Models.Tv; - -using RestSharp; - -namespace PlexRequests.Api -{ - [Obsolete("Use TVMazeAPP")] - public class TheTvDbApi : TvBase - { - public TheTvDbApi() - { - Api = new ApiRequest(); - } - private ApiRequest Api { get; } - - /// - /// Authenticates against TheTVDB. - /// - /// - public string Authenticate() - { - var request = new RestRequest - { - Method = Method.POST, - Resource = "login", - RequestFormat = DataFormat.Json, - - }; - var apiKey = new { apikey = ApiKey }; - - request.AddBody(apiKey); - request.AddHeader("Content-Type", "application/json"); - - return Api.Execute(request, Url).token; - } - - /// - /// Refreshes the token. - /// - /// The old token. - /// - public Authentication RefreshToken(string oldToken) - { - var request = new RestRequest - { - Method = Method.POST, - Resource = "refresh_token" - }; - request.AddHeader("Authorization", $"Bearer {oldToken}"); - request.AddHeader("Content-Type", "application/json"); - - return Api.Execute(request, Url); - } - - /// - /// Searches for a tv series. - /// - /// The search term. - /// The token. - /// - public TvSearchResult SearchTv(string searchTerm, string token) - { - var request = new RestRequest - { - Method = Method.GET, - Resource = "search/series?name={searchTerm}" - }; - request.AddUrlSegment("searchTerm", searchTerm); - request.AddHeader("Authorization", $"Bearer {token}"); - request.AddHeader("Content-Type", "application/json"); - - return Api.Execute(request, Url); - } - - /// - /// Gets the tv images. - /// - /// The series identifier. - /// The token. - /// - public TvShowImages GetTvImages(int seriesId, string token) - { - var request = new RestRequest - { - Method = Method.GET, - Resource = "/series/{id}/images/query?keyType=poster" - }; - request.AddUrlSegment("id", seriesId.ToString()); - request.AddHeader("Authorization", $"Bearer {token}"); - request.AddHeader("Content-Type", "application/json"); - - return Api.Execute(request, Url); - } - - - /// - /// Gets the information for a TV Series. - /// - /// The TVDB identifier. - /// The token. - /// - public TvShowInformation GetInformation(int tvdbId, string token) - { - var request = new RestRequest - { - Method = Method.GET, - Resource = "series/{id}" - }; - request.AddUrlSegment("id", tvdbId.ToString()); - request.AddHeader("Authorization", $"Bearer {token}"); - request.AddHeader("Content-Type", "application/json"); - - return Api.Execute(request, Url); - } - } -} +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: TheTvDbApi.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; + +using PlexRequests.Api.Models.Tv; + +using RestSharp; + +namespace PlexRequests.Api +{ + [Obsolete("Use TVMazeAPP")] + public class TheTvDbApi : TvBase + { + public TheTvDbApi() + { + Api = new ApiRequest(); + } + private ApiRequest Api { get; } + + /// + /// Authenticates against TheTVDB. + /// + /// + public string Authenticate() + { + var request = new RestRequest + { + Method = Method.POST, + Resource = "login", + RequestFormat = DataFormat.Json, + + }; + var apiKey = new { apikey = ApiKey }; + + request.AddBody(apiKey); + request.AddHeader("Content-Type", "application/json"); + + return Api.Execute(request, Url).token; + } + + /// + /// Refreshes the token. + /// + /// The old token. + /// + public Authentication RefreshToken(string oldToken) + { + var request = new RestRequest + { + Method = Method.POST, + Resource = "refresh_token" + }; + request.AddHeader("Authorization", $"Bearer {oldToken}"); + request.AddHeader("Content-Type", "application/json"); + + return Api.Execute(request, Url); + } + + /// + /// Searches for a tv series. + /// + /// The search term. + /// The token. + /// + public TvSearchResult SearchTv(string searchTerm, string token) + { + var request = new RestRequest + { + Method = Method.GET, + Resource = "search/series?name={searchTerm}" + }; + request.AddUrlSegment("searchTerm", searchTerm); + request.AddHeader("Authorization", $"Bearer {token}"); + request.AddHeader("Content-Type", "application/json"); + + return Api.Execute(request, Url); + } + + /// + /// Gets the tv images. + /// + /// The series identifier. + /// The token. + /// + public TvShowImages GetTvImages(int seriesId, string token) + { + var request = new RestRequest + { + Method = Method.GET, + Resource = "/series/{id}/images/query?keyType=poster" + }; + request.AddUrlSegment("id", seriesId.ToString()); + request.AddHeader("Authorization", $"Bearer {token}"); + request.AddHeader("Content-Type", "application/json"); + + return Api.Execute(request, Url); + } + + + /// + /// Gets the information for a TV Series. + /// + /// The TVDB identifier. + /// The token. + /// + public TvShowInformation GetInformation(int tvdbId, string token) + { + var request = new RestRequest + { + Method = Method.GET, + Resource = "series/{id}" + }; + request.AddUrlSegment("id", tvdbId.ToString()); + request.AddHeader("Authorization", $"Bearer {token}"); + request.AddHeader("Content-Type", "application/json"); + + return Api.Execute(request, Url); + } + } +} diff --git a/PlexRequests.Api/TvBase.cs b/PlexRequests.Api/TvBase.cs index 43555fede..3c20b6274 100644 --- a/PlexRequests.Api/TvBase.cs +++ b/PlexRequests.Api/TvBase.cs @@ -1,39 +1,39 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: MovieBase.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; - -using PlexRequests.Helpers; - -namespace PlexRequests.Api -{ - public abstract class TvBase - { - private static readonly string Encrypted = "AVdhrVK6XX8anvrQgEyN/qNr9rk8ZPwy7/r1t5t5cKyUEzxcyk0L1v6dSxgE7hTCxvITUX2cWa6VlFMlTMgJWyuPZml7fN3csCHntgd/VGYro6VfNf24snZ/rQ3mf005"; - protected string ApiKey = StringCipher.Decrypt(Encrypted, "ApiKey"); - protected Uri Url = new Uri("https://api-beta.thetvdb.com/"); - } -} +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: MovieBase.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; + +using PlexRequests.Helpers; + +namespace PlexRequests.Api +{ + public abstract class TvBase + { + private static readonly string Encrypted = "AVdhrVK6XX8anvrQgEyN/qNr9rk8ZPwy7/r1t5t5cKyUEzxcyk0L1v6dSxgE7hTCxvITUX2cWa6VlFMlTMgJWyuPZml7fN3csCHntgd/VGYro6VfNf24snZ/rQ3mf005"; + protected string ApiKey = StringCipher.Decrypt(Encrypted, "ApiKey"); + protected Uri Url = new Uri("https://api-beta.thetvdb.com/"); + } +} diff --git a/PlexRequests.Api/TvMazeBase.cs b/PlexRequests.Api/TvMazeBase.cs index d4eddefee..e4e723c95 100644 --- a/PlexRequests.Api/TvMazeBase.cs +++ b/PlexRequests.Api/TvMazeBase.cs @@ -1,33 +1,33 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: TvMazeBase.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 PlexRequests.Api -{ - public class TvMazeBase - { - protected string Uri = "http://api.tvmaze.com"; - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: TvMazeBase.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 PlexRequests.Api +{ + public class TvMazeBase + { + protected string Uri = "http://api.tvmaze.com"; + } } \ No newline at end of file diff --git a/PlexRequests.Core.Migration/MigrationRunner.cs b/PlexRequests.Core.Migration/MigrationRunner.cs index 5a1a67f10..d53ab8d3d 100644 --- a/PlexRequests.Core.Migration/MigrationRunner.cs +++ b/PlexRequests.Core.Migration/MigrationRunner.cs @@ -23,41 +23,30 @@ namespace PlexRequests.Core.Migration { var con = Db.DbConnection(); var versions = GetMigrations(); - - var dbVersion = con.GetVersionInfo().OrderByDescending(x => x.Version).FirstOrDefault(); - if (dbVersion == null) - { - dbVersion = new TableCreation.VersionInfo { Version = 0 }; - } + + var dbVersion = con.GetVersionInfo().OrderByDescending(x => x.Version).FirstOrDefault() ?? + new TableCreation.VersionInfo { Version = 0 }; foreach (var v in versions) { +#if !DEBUG if (v.Value.Version > dbVersion.Version) { - // Assuming only one constructor - var ctor = v.Key.GetConstructors().FirstOrDefault(); - var dependencies = new List(); +#endif + // Assuming only one constructor + var ctor = v.Key.GetConstructors().FirstOrDefault(); + var dependencies = ctor.GetParameters().Select(param => Kernel.Get(param.ParameterType)).ToList(); - foreach (var param in ctor.GetParameters()) - { - Console.WriteLine(string.Format( - "Param {0} is named {1} and is of type {2}", - param.Position, param.Name, param.ParameterType)); + var method = v.Key.GetMethod("Start"); + if (method != null) + { + var classInstance = Activator.CreateInstance(v.Key, dependencies.Any() ? dependencies.ToArray() : null); + var parametersArray = new object[] { Db.DbConnection() }; - var dep = Kernel.Get(param.ParameterType); - dependencies.Add(dep); - } - - var method = v.Key.GetMethod("Start"); - if (method != null) - { - object result = null; - var classInstance = Activator.CreateInstance(v.Key, dependencies.Any() ? dependencies.ToArray() : null); - - var parametersArray = new object[] { Db.DbConnection() }; - - method.Invoke(classInstance, parametersArray); - } + method.Invoke(classInstance, parametersArray); } +#if !DEBUG + } +#endif } } diff --git a/PlexRequests.Core.Migration/Migrations/Version1100.cs b/PlexRequests.Core.Migration/Migrations/Version1100.cs index fe03daf88..15c127d6e 100644 --- a/PlexRequests.Core.Migration/Migrations/Version1100.cs +++ b/PlexRequests.Core.Migration/Migrations/Version1100.cs @@ -25,34 +25,250 @@ // ************************************************************************/ #endregion +using System; +using System.Collections.Generic; using System.Data; +using NLog; +using System.Linq; +using PlexRequests.Api.Interfaces; +using PlexRequests.Core.SettingModels; +using PlexRequests.Core.Users; +using PlexRequests.Helpers; +using PlexRequests.Helpers.Permissions; using PlexRequests.Store; +using PlexRequests.Store.Models; +using PlexRequests.Store.Repository; namespace PlexRequests.Core.Migration.Migrations { [Migration(11000, "v1.10.0.0")] public class Version1100 : BaseMigration, IMigration { - public Version1100() + public Version1100(IUserRepository userRepo, IRequestService requestService, ISettingsService log, IPlexApi plexApi, ISettingsService plexService, + IPlexUserRepository plexusers, ISettingsService prSettings, ISettingsService umSettings, + ISettingsService sjs, IRepository usersToNotify) { - + UserRepo = userRepo; + RequestService = requestService; + Log = log; + PlexApi = plexApi; + PlexSettings = plexService; + PlexUsers = plexusers; + PlexRequestSettings = prSettings; + UserManagementSettings = umSettings; + ScheduledJobSettings = sjs; + UserNotifyRepo = usersToNotify; } public int Version => 11000; - + private IUserRepository UserRepo { get; } + private IRequestService RequestService { get; } + private ISettingsService Log { get; } + private IPlexApi PlexApi { get; } + private ISettingsService PlexSettings { get; } + private IPlexUserRepository PlexUsers { get; } + private ISettingsService PlexRequestSettings { get; } + private ISettingsService UserManagementSettings { get; } + private ISettingsService ScheduledJobSettings { get; } + private IRepository UserNotifyRepo { get; } public void Start(IDbConnection con) { UpdateDb(con); + // Update the current admin permissions set + + PopulateDefaultUserManagementSettings(); + UpdateAdmin(); + ResetLogLevel(); + UpdatePlexUsers(); + UpdateScheduledJobs(); + MigrateUserNotifications(); + UpdateSchema(con, Version); } + private void MigrateUserNotifications() + { + var usersToNotify = UserNotifyRepo.GetAll(); + var plexUsers = PlexUsers.GetAll().ToList(); + var users = UserRepo.GetAll().ToList(); + + if (usersToNotify == null) + { + return; + } + + foreach (var u in usersToNotify) + { + var selectedPlexUser = plexUsers.FirstOrDefault(x => x.Username.Equals(u.Username, StringComparison.CurrentCultureIgnoreCase)); + if (selectedPlexUser != null) + { + selectedPlexUser.Features += (int)Features.RequestAddedNotification; + PlexUsers.Update(selectedPlexUser); + } + + var selectedLocalUser = + users.FirstOrDefault(x => x.UserName.Equals(u.Username, StringComparison.CurrentCultureIgnoreCase)); + if (selectedLocalUser != null) + { + selectedLocalUser.Features += (int)Features.RequestAddedNotification; + UserRepo.Update(selectedLocalUser); + } + + } + } + + private void UpdateScheduledJobs() + { + var settings = ScheduledJobSettings.GetSettings(); + + settings.PlexUserChecker = 24; + settings.PlexContentCacher = 60; + + ScheduledJobSettings.SaveSettings(settings); + } + + private void PopulateDefaultUserManagementSettings() + { + var plexRequestSettings = PlexRequestSettings.GetSettings(); + + UserManagementSettings.SaveSettings(new UserManagementSettings + { + AutoApproveMovies = !plexRequestSettings.RequireMovieApproval, + RequestTvShows = plexRequestSettings.SearchForTvShows, + RequestMusic = plexRequestSettings.SearchForMusic, + RequestMovies = plexRequestSettings.SearchForMovies, + AutoApproveMusic = !plexRequestSettings.RequireMusicApproval, + AutoApproveTvShows = !plexRequestSettings.RequireTvShowApproval + }); + } + + private void UpdatePlexUsers() + { + var settings = PlexSettings.GetSettings(); + if (string.IsNullOrEmpty(settings.PlexAuthToken)) + { + return; + } + var plexUsers = PlexApi.GetUsers(settings.PlexAuthToken); + + if (plexUsers?.User == null) + { + return; + } + + var prSettings = PlexRequestSettings.GetSettings(); + + var dbUsers = PlexUsers.GetAll().ToList(); + foreach (var user in plexUsers.User) + { + if (dbUsers.FirstOrDefault(x => x.PlexUserId == user.Id) != null) + { + continue; + } + + int permissions = 0; + if (prSettings.SearchForMovies) + { + permissions = (int)Permissions.RequestMovie; + } + if (prSettings.SearchForTvShows) + { + permissions += (int)Permissions.RequestTvShow; + } + if (prSettings.SearchForMusic) + { + permissions += (int)Permissions.RequestMusic; + } + if (!prSettings.RequireMovieApproval) + { + permissions += (int)Permissions.AutoApproveMovie; + } + if (!prSettings.RequireTvShowApproval) + { + permissions += (int)Permissions.AutoApproveTv; + } + if (!prSettings.RequireMusicApproval) + { + permissions += (int)Permissions.AutoApproveAlbum; + } + + // Add report Issues + + permissions += (int)Permissions.ReportIssue; + + var m = new PlexUsers + { + PlexUserId = user.Id, + Permissions = permissions, + Features = 0, + UserAlias = string.Empty, + EmailAddress = user.Email, + Username = user.Username, + LoginId = Guid.NewGuid().ToString() + }; + + PlexUsers.Insert(m); + } + + } + + private void ResetLogLevel() + { + var logSettings = Log.GetSettings(); + logSettings.Level = LogLevel.Error.Ordinal; + Log.SaveSettings(logSettings); + + LoggingHelper.ReconfigureLogLevel(LogLevel.FromOrdinal(logSettings.Level)); + } + private void UpdateDb(IDbConnection con) { // Create the two new columns con.AlterTable("Users", "ADD", "Permissions", true, "INTEGER"); con.AlterTable("Users", "ADD", "Features", true, "INTEGER"); - + + con.AlterTable("PlexUsers", "ADD", "Permissions", true, "INTEGER"); + con.AlterTable("PlexUsers", "ADD", "Features", true, "INTEGER"); + con.AlterTable("PlexUsers", "ADD", "Username", true, "VARCHAR(100)"); + con.AlterTable("PlexUsers", "ADD", "EmailAddress", true, "VARCHAR(100)"); + con.AlterTable("PlexUsers", "ADD", "LoginId", true, "VARCHAR(100)"); + + //https://image.tmdb.org/t/p/w150/https://image.tmdb.org/t/p/w150//aqhAqttDq7zgsTaBHtCD8wmTk6k.jpg + + // UI = https://image.tmdb.org/t/p/w150/{{posterPath}} + // Update old invalid posters + var allRequests = RequestService.GetAll().ToList(); + + foreach (var req in allRequests) + { + if (req.PosterPath.Contains("https://image.tmdb.org/t/p/w150/")) + { + var newImg = req.PosterPath.Replace("https://image.tmdb.org/t/p/w150/", string.Empty); + req.PosterPath = newImg; + } + } + RequestService.BatchUpdate(allRequests); + } + + private void UpdateAdmin() + { + var users = UserRepo.GetAll().ToList(); + + foreach (var user in users) + { + user.Permissions = (int) + (Permissions.Administrator + | Permissions.ReportIssue + | Permissions.RequestMusic + | Permissions.RequestTvShow + | Permissions.RequestMovie + | Permissions.AutoApproveAlbum + | Permissions.AutoApproveMovie + | Permissions.AutoApproveTv); + } + + UserRepo.UpdateAll(users); } } -} \ No newline at end of file +} diff --git a/PlexRequests.Core.Migration/PlexRequests.Core.Migration.csproj b/PlexRequests.Core.Migration/PlexRequests.Core.Migration.csproj index 2881f95ed..0b582b68b 100644 --- a/PlexRequests.Core.Migration/PlexRequests.Core.Migration.csproj +++ b/PlexRequests.Core.Migration/PlexRequests.Core.Migration.csproj @@ -45,6 +45,10 @@ ..\packages\Ninject.3.2.0.0\lib\net45-full\Ninject.dll + + ..\packages\NLog.4.3.11\lib\net45\NLog.dll + True + ..\packages\Quartz.2.3.3\lib\net40\Quartz.dll True @@ -70,10 +74,22 @@ + + {95834072-A675-415D-AA8F-877C91623810} + PlexRequests.Api.Interfaces + + + {CB37A5F8-6DFC-4554-99D3-A42B502E4591} + PlexRequests.Api.Models + {DD7DC444-D3BF-4027-8AB9-EFC71F5EC581} PlexRequests.Core + + {1252336D-42A3-482A-804C-836E60173DFA} + PlexRequests.Helpers + {92433867-2B7B-477B-A566-96C382427525} PlexRequests.Store diff --git a/PlexRequests.Core.Migration/packages.config b/PlexRequests.Core.Migration/packages.config index dfdfc5ae9..6d547be19 100644 --- a/PlexRequests.Core.Migration/packages.config +++ b/PlexRequests.Core.Migration/packages.config @@ -2,5 +2,6 @@ + \ No newline at end of file diff --git a/PlexRequests.Core.Tests/PlexRequests.Core.Tests.csproj b/PlexRequests.Core.Tests/PlexRequests.Core.Tests.csproj index 0e6f4d3e0..5002e3c21 100644 --- a/PlexRequests.Core.Tests/PlexRequests.Core.Tests.csproj +++ b/PlexRequests.Core.Tests/PlexRequests.Core.Tests.csproj @@ -60,7 +60,6 @@ - diff --git a/PlexRequests.Core.Tests/Properties/AssemblyInfo.cs b/PlexRequests.Core.Tests/Properties/AssemblyInfo.cs index 1cc04fc46..ce0830f7e 100644 --- a/PlexRequests.Core.Tests/Properties/AssemblyInfo.cs +++ b/PlexRequests.Core.Tests/Properties/AssemblyInfo.cs @@ -1,37 +1,37 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("PlexRequests.Core.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("PlexRequests.Core.Tests")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("fcfecd5d-47f6-454d-8692-e27a921be655")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] -[assembly: AssemblyInformationalVersionAttribute("1.0.0.0")] +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("PlexRequests.Core.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PlexRequests.Core.Tests")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("fcfecd5d-47f6-454d-8692-e27a921be655")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyInformationalVersionAttribute("1.0.0.0")] diff --git a/PlexRequests.Core/CacheKeys.cs b/PlexRequests.Core/CacheKeys.cs index 0f718f1f1..e40dd9efd 100644 --- a/PlexRequests.Core/CacheKeys.cs +++ b/PlexRequests.Core/CacheKeys.cs @@ -30,7 +30,7 @@ namespace PlexRequests.Core { public struct TimeFrameMinutes { - public const int SchedulerCaching = 60; + public const int SchedulerCaching = 120; } public const string PlexLibaries = nameof(PlexLibaries); diff --git a/PlexRequests.UI/Helpers/HeadphonesSender.cs b/PlexRequests.Core/HeadphonesSender.cs similarity index 96% rename from PlexRequests.UI/Helpers/HeadphonesSender.cs rename to PlexRequests.Core/HeadphonesSender.cs index 17674e891..19e438be2 100644 --- a/PlexRequests.UI/Helpers/HeadphonesSender.cs +++ b/PlexRequests.Core/HeadphonesSender.cs @@ -1,176 +1,174 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: HeadphonesSender.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.Linq; -using System.Threading; -using System.Threading.Tasks; - -using NLog; - -using PlexRequests.Api.Interfaces; -using PlexRequests.Core; -using PlexRequests.Core.SettingModels; -using PlexRequests.Store; - -namespace PlexRequests.UI.Helpers -{ - public class HeadphonesSender - { - public HeadphonesSender(IHeadphonesApi api, HeadphonesSettings settings, IRequestService request) - { - Api = api; - Settings = settings; - RequestService = request; - } - - private int WaitTime => 2000; - private int CounterMax => 60; - - private static readonly Logger Log = LogManager.GetCurrentClassLogger(); - private IHeadphonesApi Api { get; } - private IRequestService RequestService { get; } - private HeadphonesSettings Settings { get; } - - public async Task AddAlbum(RequestedModel request) - { - var addArtistResult = await AddArtist(request); - if (!addArtistResult) - { - return false; - } - - // Artist is now active - // Add album - var albumResult = await Api.AddAlbum(Settings.ApiKey, Settings.FullUri, request.MusicBrainzId); - if (!albumResult) - { - Log.Error("Couldn't add the album to headphones"); - } - - // Set the status to wanted and search - var status = await SetAlbumStatus(request); - if (!status) - { - return false; - } - - // Approve it - request.Approved = true; - - // Update the record - var updated = RequestService.UpdateRequest(request); - - return updated; - } - - private async Task AddArtist(RequestedModel request) - { - var index = await Api.GetIndex(Settings.ApiKey, Settings.FullUri); - var artistExists = index.Any(x => x.ArtistID == request.ArtistId); - if (!artistExists) - { - var artistAdd = Api.AddArtist(Settings.ApiKey, Settings.FullUri, request.ArtistId); - Log.Info("Artist add result : {0}", artistAdd); - } - - var counter = 0; - while (index.All(x => x.ArtistID != request.ArtistId)) - { - Thread.Sleep(WaitTime); - counter++; - Log.Trace("Artist is still not present in the index. Counter = {0}", counter); - index = await Api.GetIndex(Settings.ApiKey, Settings.FullUri); - - if (counter > CounterMax) - { - Log.Trace("Artist is still not present in the index. Counter = {0}. Returning false", counter); - Log.Warn("We have tried adding the artist but it seems they are still not in headphones."); - return false; - } - } - - counter = 0; - var artistStatus = index.Where(x => x.ArtistID == request.ArtistId).Select(x => x.Status).FirstOrDefault(); - while (artistStatus != "Active") - { - Thread.Sleep(WaitTime); - counter++; - Log.Trace("Artist status {1}. Counter = {0}", counter, artistStatus); - index = await Api.GetIndex(Settings.ApiKey, Settings.FullUri); - artistStatus = index.Where(x => x.ArtistID == request.ArtistId).Select(x => x.Status).FirstOrDefault(); - if (counter > CounterMax) - { - Log.Trace("Artist status is still not active. Counter = {0}. Returning false", counter); - Log.Warn("The artist status is still not Active. We have waited long enough, seems to be a big delay in headphones."); - return false; - } - } - - var addedArtist = index.FirstOrDefault(x => x.ArtistID == request.ArtistId); - var artistName = addedArtist?.ArtistName ?? string.Empty; - counter = 0; - while (artistName.Contains("Fetch failed")) - { - Thread.Sleep(WaitTime); - await Api.RefreshArtist(Settings.ApiKey, Settings.FullUri, request.ArtistId); - - index = await Api.GetIndex(Settings.ApiKey, Settings.FullUri); - - artistName = index?.FirstOrDefault(x => x.ArtistID == request.ArtistId)?.ArtistName ?? string.Empty; - counter++; - if (counter > CounterMax) - { - Log.Trace("Artist fetch has failed. Counter = {0}. Returning false", counter); - Log.Warn("Artist in headphones fetch has failed, we have tried refreshing the artist but no luck."); - return false; - } - } - - return true; - } - - private async Task SetAlbumStatus(RequestedModel request) - { - var counter = 0; - var setStatus = await Api.QueueAlbum(Settings.ApiKey, Settings.FullUri, request.MusicBrainzId); - - while (!setStatus) - { - Thread.Sleep(WaitTime); - counter++; - Log.Trace("Setting Album status. Counter = {0}", counter); - setStatus = await Api.QueueAlbum(Settings.ApiKey, Settings.FullUri, request.MusicBrainzId); - if (counter > CounterMax) - { - Log.Trace("Album status is still not active. Counter = {0}. Returning false", counter); - Log.Warn("We tried to se the status for the album but headphones didn't want to snatch it."); - return false; - } - } - return true; - } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: HeadphonesSender.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.Linq; +using System.Threading; +using System.Threading.Tasks; +using NLog; +using PlexRequests.Api.Interfaces; +using PlexRequests.Core.SettingModels; +using PlexRequests.Store; + +namespace PlexRequests.Core +{ + public class HeadphonesSender + { + public HeadphonesSender(IHeadphonesApi api, HeadphonesSettings settings, IRequestService request) + { + Api = api; + Settings = settings; + RequestService = request; + } + + private int WaitTime => 2000; + private int CounterMax => 60; + + private static readonly Logger Log = LogManager.GetCurrentClassLogger(); + private IHeadphonesApi Api { get; } + private IRequestService RequestService { get; } + private HeadphonesSettings Settings { get; } + + public async Task AddAlbum(RequestedModel request) + { + var addArtistResult = await AddArtist(request); + if (!addArtistResult) + { + return false; + } + + // Artist is now active + // Add album + var albumResult = await Api.AddAlbum(Settings.ApiKey, Settings.FullUri, request.MusicBrainzId); + if (!albumResult) + { + Log.Error("Couldn't add the album to headphones"); + } + + // Set the status to wanted and search + var status = await SetAlbumStatus(request); + if (!status) + { + return false; + } + + // Approve it + request.Approved = true; + + // Update the record + var updated = RequestService.UpdateRequest(request); + + return updated; + } + + private async Task AddArtist(RequestedModel request) + { + var index = await Api.GetIndex(Settings.ApiKey, Settings.FullUri); + var artistExists = index.Any(x => x.ArtistID == request.ArtistId); + if (!artistExists) + { + var artistAdd = Api.AddArtist(Settings.ApiKey, Settings.FullUri, request.ArtistId); + Log.Info("Artist add result : {0}", artistAdd); + } + + var counter = 0; + while (index.All(x => x.ArtistID != request.ArtistId)) + { + Thread.Sleep(WaitTime); + counter++; + Log.Trace("Artist is still not present in the index. Counter = {0}", counter); + index = await Api.GetIndex(Settings.ApiKey, Settings.FullUri); + + if (counter > CounterMax) + { + Log.Trace("Artist is still not present in the index. Counter = {0}. Returning false", counter); + Log.Warn("We have tried adding the artist but it seems they are still not in headphones."); + return false; + } + } + + counter = 0; + var artistStatus = index.Where(x => x.ArtistID == request.ArtistId).Select(x => x.Status).FirstOrDefault(); + while (artistStatus != "Active") + { + Thread.Sleep(WaitTime); + counter++; + Log.Trace("Artist status {1}. Counter = {0}", counter, artistStatus); + index = await Api.GetIndex(Settings.ApiKey, Settings.FullUri); + artistStatus = index.Where(x => x.ArtistID == request.ArtistId).Select(x => x.Status).FirstOrDefault(); + if (counter > CounterMax) + { + Log.Trace("Artist status is still not active. Counter = {0}. Returning false", counter); + Log.Warn("The artist status is still not Active. We have waited long enough, seems to be a big delay in headphones."); + return false; + } + } + + var addedArtist = index.FirstOrDefault(x => x.ArtistID == request.ArtistId); + var artistName = addedArtist?.ArtistName ?? string.Empty; + counter = 0; + while (artistName.Contains("Fetch failed")) + { + Thread.Sleep(WaitTime); + await Api.RefreshArtist(Settings.ApiKey, Settings.FullUri, request.ArtistId); + + index = await Api.GetIndex(Settings.ApiKey, Settings.FullUri); + + artistName = index?.FirstOrDefault(x => x.ArtistID == request.ArtistId)?.ArtistName ?? string.Empty; + counter++; + if (counter > CounterMax) + { + Log.Trace("Artist fetch has failed. Counter = {0}. Returning false", counter); + Log.Warn("Artist in headphones fetch has failed, we have tried refreshing the artist but no luck."); + return false; + } + } + + return true; + } + + private async Task SetAlbumStatus(RequestedModel request) + { + var counter = 0; + var setStatus = await Api.QueueAlbum(Settings.ApiKey, Settings.FullUri, request.MusicBrainzId); + + while (!setStatus) + { + Thread.Sleep(WaitTime); + counter++; + Log.Trace("Setting Album status. Counter = {0}", counter); + setStatus = await Api.QueueAlbum(Settings.ApiKey, Settings.FullUri, request.MusicBrainzId); + if (counter > CounterMax) + { + Log.Trace("Album status is still not active. Counter = {0}. Returning false", counter); + Log.Warn("We tried to se the status for the album but headphones didn't want to snatch it."); + return false; + } + } + return true; + } + } } \ No newline at end of file diff --git a/PlexRequests.Core/IRequestService.cs b/PlexRequests.Core/IRequestService.cs index 740216bec..7dae2f6a7 100644 --- a/PlexRequests.Core/IRequestService.cs +++ b/PlexRequests.Core/IRequestService.cs @@ -1,57 +1,57 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: IRequestService.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.Threading.Tasks; - -using PlexRequests.Store; - -namespace PlexRequests.Core -{ - public interface IRequestService - { - long AddRequest(RequestedModel model); - Task AddRequestAsync(RequestedModel model); - RequestedModel CheckRequest(int providerId); - Task CheckRequestAsync(int providerId); - RequestedModel CheckRequest(string musicId); - Task CheckRequestAsync(string musicId); - - void DeleteRequest(RequestedModel request); - Task DeleteRequestAsync(RequestedModel request); - bool UpdateRequest(RequestedModel model); - Task UpdateRequestAsync(RequestedModel model); - RequestedModel Get(int id); - Task GetAsync(int id); - IEnumerable GetAll(); - Task> GetAllAsync(); - bool BatchUpdate(IEnumerable model); - Task BatchUpdateAsync(IEnumerable model); - bool BatchDelete(IEnumerable model); - Task BatchDeleteAsync(IEnumerable model); - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: IRequestService.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.Threading.Tasks; + +using PlexRequests.Store; + +namespace PlexRequests.Core +{ + public interface IRequestService + { + long AddRequest(RequestedModel model); + Task AddRequestAsync(RequestedModel model); + RequestedModel CheckRequest(int providerId); + Task CheckRequestAsync(int providerId); + RequestedModel CheckRequest(string musicId); + Task CheckRequestAsync(string musicId); + + void DeleteRequest(RequestedModel request); + Task DeleteRequestAsync(RequestedModel request); + bool UpdateRequest(RequestedModel model); + Task UpdateRequestAsync(RequestedModel model); + RequestedModel Get(int id); + Task GetAsync(int id); + IEnumerable GetAll(); + Task> GetAllAsync(); + bool BatchUpdate(IEnumerable model); + Task BatchUpdateAsync(IEnumerable model); + bool BatchDelete(IEnumerable model); + Task BatchDeleteAsync(IEnumerable model); + } } \ No newline at end of file diff --git a/PlexRequests.Core/ISecurityExtensions.cs b/PlexRequests.Core/ISecurityExtensions.cs new file mode 100644 index 000000000..10db3ccfe --- /dev/null +++ b/PlexRequests.Core/ISecurityExtensions.cs @@ -0,0 +1,34 @@ +using System; +using Nancy; +using Nancy.Security; +using PlexRequests.Helpers.Permissions; + +namespace PlexRequests.Core +{ + public interface ISecurityExtensions + { + Response AdminLoginRedirect(Permissions perm, NancyContext context); + Response AdminLoginRedirect(NancyContext context, params Permissions[] perm); + bool DoesNotHavePermissions(Permissions perm, IUserIdentity currentUser); + + Response HasAnyPermissionsRedirect(NancyContext context, string routeName, HttpStatusCode code, + params Permissions[] perm); + bool DoesNotHavePermissions(int perm, IUserIdentity currentUser); + Func ForbiddenIfNot(Func test); + bool HasAnyPermissions(IUserIdentity user, params Permissions[] perm); + bool HasPermissions(IUserIdentity user, Permissions perm); + Response HasPermissionsRedirect(Permissions perm, NancyContext context, string routeName, HttpStatusCode code); + Func HttpStatusCodeIfNot(HttpStatusCode statusCode, Func test); + bool IsLoggedIn(NancyContext context); + bool IsNormalUser(IUserIdentity user); + bool IsPlexUser(IUserIdentity user); + bool HasPermissions(string userName, Permissions perm); + + /// + /// Gets the username this could be the alias! We should always use this method when getting the username + /// + /// The username. + /// null if we cannot find a user + string GetUsername(string username); + } +} \ No newline at end of file diff --git a/PlexRequests.Core/ISettingsService.cs b/PlexRequests.Core/ISettingsService.cs index a1ef1341e..2b3098811 100644 --- a/PlexRequests.Core/ISettingsService.cs +++ b/PlexRequests.Core/ISettingsService.cs @@ -1,41 +1,41 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: ISettingsService.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.Threading.Tasks; - -namespace PlexRequests.Core -{ - public interface ISettingsService - { - T GetSettings(); - Task GetSettingsAsync(); - bool SaveSettings(T model); - Task SaveSettingsAsync(T model); - bool Delete(T model); - Task DeleteAsync(T model); - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: ISettingsService.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.Threading.Tasks; + +namespace PlexRequests.Core +{ + public interface ISettingsService + { + T GetSettings(); + Task GetSettingsAsync(); + bool SaveSettings(T model); + Task SaveSettingsAsync(T model); + bool Delete(T model); + Task DeleteAsync(T model); + } } \ No newline at end of file diff --git a/PlexRequests.Core/IStatusChecker.cs b/PlexRequests.Core/IStatusChecker.cs new file mode 100644 index 000000000..eec365b68 --- /dev/null +++ b/PlexRequests.Core/IStatusChecker.cs @@ -0,0 +1,11 @@ +using System.Threading.Tasks; +using Octokit; +using PlexRequests.Core.Models; + +namespace PlexRequests.Core +{ + public interface IStatusChecker + { + Task GetStatus(); + } +} \ No newline at end of file diff --git a/PlexRequests.Core/Models/NotificationType.cs b/PlexRequests.Core/Models/NotificationType.cs index a01d153dd..eace7b018 100644 --- a/PlexRequests.Core/Models/NotificationType.cs +++ b/PlexRequests.Core/Models/NotificationType.cs @@ -34,6 +34,7 @@ namespace PlexRequests.Core.Models RequestApproved, AdminNote, Test, - + RequestDeclined, + ItemAddedToFaultQueue } } diff --git a/PlexRequests.Core/Models/StatusModel.cs b/PlexRequests.Core/Models/StatusModel.cs index 62047126e..ee55ab373 100644 --- a/PlexRequests.Core/Models/StatusModel.cs +++ b/PlexRequests.Core/Models/StatusModel.cs @@ -1,38 +1,39 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: StatusModel.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 PlexRequests.Core.Models -{ - public class StatusModel - { - public string Version { get; set; } - public bool UpdateAvailable { get; set; } - public string UpdateUri { get; set; } - public string DownloadUri { get; set; } - public string ReleaseNotes { get; set; } - public string ReleaseTitle { get; set; } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: StatusModel.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 PlexRequests.Core.Models +{ + public class StatusModel + { + public string CurrentVersion { get; set; } + public string NewVersion { get; set; } + public bool UpdateAvailable { get; set; } + public string UpdateUri { get; set; } + public string DownloadUri { get; set; } + public string ReleaseNotes { get; set; } + public string ReleaseTitle { get; set; } + } } \ No newline at end of file diff --git a/PlexRequests.Core/PlexRequests.Core.csproj b/PlexRequests.Core/PlexRequests.Core.csproj index 4def9282d..f2f79067b 100644 --- a/PlexRequests.Core/PlexRequests.Core.csproj +++ b/PlexRequests.Core/PlexRequests.Core.csproj @@ -39,9 +39,17 @@ ..\packages\Common.Logging.Core.3.0.0\lib\net40\Common.Logging.Core.dll True + + ..\packages\Dapper.1.50.0-beta8\lib\net45\Dapper.dll + True + ..\Assemblies\Mono.Data.Sqlite.dll + + ..\packages\Nancy.Linker.0.3.1\lib\net40-Client\Nancy.Linker.dll + True + ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True @@ -54,7 +62,12 @@ ..\packages\Quartz.2.3.3\lib\net40\Quartz.dll True + + ..\packages\RestSharp.105.2.3\lib\net45\RestSharp.dll + True + + @@ -81,7 +94,10 @@ + + + @@ -99,7 +115,9 @@ + + @@ -120,12 +138,22 @@ + + - + + + + + + + + + diff --git a/PlexRequests.Core/Queue/ITransientFaultQueue.cs b/PlexRequests.Core/Queue/ITransientFaultQueue.cs new file mode 100644 index 000000000..ee5ea05d0 --- /dev/null +++ b/PlexRequests.Core/Queue/ITransientFaultQueue.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using PlexRequests.Store; +using PlexRequests.Store.Models; + +namespace PlexRequests.Core.Queue +{ + public interface ITransientFaultQueue + { + void Dequeue(); + Task DequeueAsync(); + IEnumerable GetQueue(); + Task> GetQueueAsync(); + void QueueItem(RequestedModel request, string id, RequestType type, FaultType faultType); + Task QueueItemAsync(RequestedModel request, string id, RequestType type, FaultType faultType, string message = null); + } +} \ No newline at end of file diff --git a/PlexRequests.Core/Queue/TransientFaultQueue.cs b/PlexRequests.Core/Queue/TransientFaultQueue.cs index e3621ee0f..2be15bfa5 100644 --- a/PlexRequests.Core/Queue/TransientFaultQueue.cs +++ b/PlexRequests.Core/Queue/TransientFaultQueue.cs @@ -26,7 +26,9 @@ #endregion using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; +using Dapper; using PlexRequests.Helpers; using PlexRequests.Store; using PlexRequests.Store.Models; @@ -34,7 +36,7 @@ using PlexRequests.Store.Repository; namespace PlexRequests.Core.Queue { - public class TransientFaultQueue + public class TransientFaultQueue : ITransientFaultQueue { public TransientFaultQueue(IRepository queue) { @@ -44,44 +46,85 @@ namespace PlexRequests.Core.Queue private IRepository RequestQueue { get; } - public void QueueItem(RequestedModel request, RequestType type) + public void QueueItem(RequestedModel request, string id, RequestType type, FaultType faultType) { + //Ensure there is not a duplicate queued item + var existingItem = RequestQueue.Custom( + connection => + { + connection.Open(); + var result = connection.Query("select * from RequestQueue where PrimaryIdentifier = @ProviderId", new { ProviderId = id }); + + return result; + }).FirstOrDefault(); + + if (existingItem != null) + { + // It's already in the queue + return; + } + var queue = new RequestQueue { Type = type, Content = ByteConverterHelper.ReturnBytes(request), - PrimaryIdentifier = request.ProviderId + PrimaryIdentifier = id, + FaultType = faultType }; RequestQueue.Insert(queue); } - public async Task QueueItemAsync(RequestedModel request, RequestType type) + public async Task QueueItemAsync(RequestedModel request, string id, RequestType type, FaultType faultType, string description = null) { + //Ensure there is not a duplicate queued item + var existingItem = await RequestQueue.CustomAsync(async connection => + { + connection.Open(); + var result = await connection.QueryAsync("select * from RequestFaultQueue where PrimaryIdentifier = @ProviderId", new { ProviderId = id }); + + return result; + }); + + if (existingItem.FirstOrDefault() != null) + { + // It's already in the queue + return; + } + var queue = new RequestQueue { Type = type, Content = ByteConverterHelper.ReturnBytes(request), - PrimaryIdentifier = request.ProviderId + PrimaryIdentifier = id, + FaultType = faultType, + Message = description ?? string.Empty }; await RequestQueue.InsertAsync(queue); } - public IEnumerable Dequeue() + public IEnumerable GetQueue() { var items = RequestQueue.GetAll(); - RequestQueue.DeleteAll("RequestQueue"); return items; } - public async Task> DequeueAsync() + public async Task> GetQueueAsync() { var items = RequestQueue.GetAllAsync(); - - await RequestQueue.DeleteAllAsync("RequestQueue"); - + return await items; } + + public void Dequeue() + { + RequestQueue.DeleteAll("RequestQueue"); + } + + public async Task DequeueAsync() + { + await RequestQueue.DeleteAllAsync("RequestQueue"); + } } } \ No newline at end of file diff --git a/PlexRequests.Core/SecurityExtensions.cs b/PlexRequests.Core/SecurityExtensions.cs new file mode 100644 index 000000000..38972cf22 --- /dev/null +++ b/PlexRequests.Core/SecurityExtensions.cs @@ -0,0 +1,302 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: SecurityExtensions.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; +using Nancy; +using Nancy.Linker; +using Nancy.Responses; +using Nancy.Security; +using PlexRequests.Core.Models; +using PlexRequests.Helpers; +using PlexRequests.Helpers.Permissions; +using PlexRequests.Store.Repository; +using ISecurityExtensions = PlexRequests.Core.ISecurityExtensions; + +namespace PlexRequests.Core +{ + public class SecurityExtensions : ISecurityExtensions + { + public SecurityExtensions(IUserRepository userRepository, IResourceLinker linker, IPlexUserRepository plexUsers) + { + UserRepository = userRepository; + Linker = linker; + PlexUsers = plexUsers; + } + + private IUserRepository UserRepository { get; } + private IResourceLinker Linker { get; } + private IPlexUserRepository PlexUsers { get; } + + public bool IsLoggedIn(NancyContext context) + { + var userName = context.Request.Session[SessionKeys.UsernameKey]; + var realUser = false; + var plexUser = userName != null; + + if (context.CurrentUser?.IsAuthenticated() ?? false) + { + realUser = true; + } + + return realUser || plexUser; + } + + public bool IsPlexUser(IUserIdentity user) + { + if (user == null) + { + return false; + } + var plexUser = PlexUsers.GetUserByUsername(user.UserName); + return plexUser != null; + } + + public bool IsNormalUser(IUserIdentity user) + { + if (user == null) + { + return false; + } + var dbUser = UserRepository.GetUserByUsername(user.UserName); + + return dbUser != null; + } + + /// + /// Gets the username this could be the alias! We should always use this method when getting the username + /// + /// The username. + /// null if we cannot find a user + public string GetUsername(string username) + { + var plexUser = PlexUsers.GetUserByUsername(username); + if (plexUser != null) + { + if (!string.IsNullOrEmpty(plexUser.UserAlias)) + { + return plexUser.UserAlias; + } + else + { + return plexUser.Username; + } + } + + var dbUser = UserRepository.GetUserByUsername(username); + if (dbUser != null) + { + var userProps = ByteConverterHelper.ReturnObject(dbUser.UserProperties); + if (!string.IsNullOrEmpty(userProps.UserAlias)) + { + return userProps.UserAlias; + } + else + { + return dbUser.UserName; + } + } + return null; + } + + + /// + /// Creates a hook to be used in a pipeline before a route handler to ensure + /// that the request was made by an authenticated user does not have the claims. + /// + /// Claims the authenticated user needs to have + /// Hook that returns an Unauthorized response if the user is not + /// authenticated or does have the claims, null otherwise + private Func DoesNotHavePermissions(int perm) + { + return ForbiddenIfNot(ctx => + { + var permissions = GetPermissions(ctx.CurrentUser); + var result = permissions.HasFlag((Permissions)perm); + return !result; + }); + } + + public bool DoesNotHavePermissions(int perm, IUserIdentity currentUser) + { + return DoesNotHavePermissions((Permissions)perm, currentUser); + } + + public bool DoesNotHavePermissions(Permissions perm, IUserIdentity currentUser) + { + var permissions = GetPermissions(currentUser); + var result = permissions.HasFlag(perm); + return !result; + } + + public bool HasPermissions(IUserIdentity user, Permissions perm) + { + var permissions = GetPermissions(user); + return permissions.HasFlag(perm); + } + public bool HasPermissions(string userName, Permissions perm) + { + var permissions = GetPermissions(userName); + return permissions.HasFlag(perm); + } + + public bool HasAnyPermissions(IUserIdentity user, params Permissions[] perm) + { + var permissions = GetPermissions(user); + + foreach (var p in perm) + { + var result = permissions.HasFlag(p); + if (result) + { + return true; + } + } + + return false; + } + + public Response HasPermissionsRedirect(Permissions perm, NancyContext context, string routeName, HttpStatusCode code) + { + var url = Linker.BuildRelativeUri(context, routeName); + + var response = ForbiddenIfNot(ctx => + { + var permissions = GetPermissions(ctx.CurrentUser); + var result = permissions.HasFlag(perm); + return result; + }); + + var r = response(context); + return r.StatusCode == code + ? new RedirectResponse($"{url.ToString()}?redirect={context.Request.Path}") + : null; + } + public Response HasAnyPermissionsRedirect(NancyContext context, string routeName, HttpStatusCode code, params Permissions[] perm) + { + var url = Linker.BuildRelativeUri(context, routeName); + + var response = ForbiddenIfNot(ctx => + { + var permissions = GetPermissions(ctx.CurrentUser); + var hasPermission = false; + foreach (var p in perm) + { + var result = permissions.HasFlag(p); + if (result) + { + hasPermission = true; + } + } + return hasPermission; + }); + + var r = response(context); + return r.StatusCode == code + ? new RedirectResponse(url.ToString()) + : null; + } + + + public Response AdminLoginRedirect(Permissions perm, NancyContext context) + { + // This will redirect us to the Login Page if we don't have the correct permission passed in (e.g. Admin with Http 403 status code). + return HasPermissionsRedirect(perm, context, "LocalLogin", HttpStatusCode.Forbidden); + } + + public Response AdminLoginRedirect(NancyContext context, params Permissions[] perm) + { + // This will redirect us to the Login Page if we don't have the correct permission passed in (e.g. Admin with Http 403 status code). + return HasAnyPermissionsRedirect(context, "LocalLogin", HttpStatusCode.Forbidden, perm); + } + + // BELOW IS A COPY FROM THE SecurityHooks CLASS! + + /// + /// Creates a hook to be used in a pipeline before a route handler to ensure that + /// the request satisfies a specific test. + /// + /// Test that must return true for the request to continue + /// Hook that returns an Forbidden response if the test fails, null otherwise + public Func ForbiddenIfNot(Func test) + { + return HttpStatusCodeIfNot(HttpStatusCode.Forbidden, test); + } + + /// + /// Creates a hook to be used in a pipeline before a route handler to ensure that + /// the request satisfies a specific test. + /// + /// HttpStatusCode to use for the response + /// Test that must return true for the request to continue + /// Hook that returns a response with a specific HttpStatusCode if the test fails, null otherwise + public Func HttpStatusCodeIfNot(HttpStatusCode statusCode, Func test) + { + return ctx => + { + Response response = new Response + { + StatusCode = HttpStatusCode.OK + }; + if (!test(ctx)) + { + response = new Response + { + StatusCode = statusCode + }; + } + return response; + }; + } + + private Permissions GetPermissions(IUserIdentity user) + { + return GetPermissions(user?.UserName); + } + + private Permissions GetPermissions(string userName) + { + if (string.IsNullOrEmpty(userName)) return 0; + + var dbUser = UserRepository.GetUserByUsername(userName); + + if (dbUser != null) + { + var permissions = (Permissions)dbUser.Permissions; + return permissions; + } + + var plexUser = PlexUsers.GetUserByUsername(userName); + if (plexUser != null) + { + var permissions = (Permissions)plexUser.Permissions; + return permissions; + } + + return 0; + } + } +} \ No newline at end of file diff --git a/PlexRequests.Core/SettingModels/PlexRequestSettings.cs b/PlexRequests.Core/SettingModels/PlexRequestSettings.cs index 5c7e6ddf5..2a0713375 100644 --- a/PlexRequests.Core/SettingModels/PlexRequestSettings.cs +++ b/PlexRequests.Core/SettingModels/PlexRequestSettings.cs @@ -44,10 +44,16 @@ namespace PlexRequests.Core.SettingModels public bool SearchForMovies { get; set; } public bool SearchForTvShows { get; set; } public bool SearchForMusic { get; set; } + [Obsolete("Use the user management settings")] public bool RequireMovieApproval { get; set; } + [Obsolete("Use the user management settings")] public bool RequireTvShowApproval { get; set; } + [Obsolete("Use the user management settings")] public bool RequireMusicApproval { get; set; } + + [Obsolete("Use the user management settings")] public bool UsersCanViewOnlyOwnRequests { get; set; } + [Obsolete("Use the user management settings")] public bool UsersCanViewOnlyOwnIssues { get; set; } public int MovieWeeklyRequestLimit { get; set; } public int TvWeeklyRequestLimit { get; set; } diff --git a/PlexRequests.Core/SettingModels/ScheduledJobsSettings.cs b/PlexRequests.Core/SettingModels/ScheduledJobsSettings.cs index 234dc5774..d0e6b05e1 100644 --- a/PlexRequests.Core/SettingModels/ScheduledJobsSettings.cs +++ b/PlexRequests.Core/SettingModels/ScheduledJobsSettings.cs @@ -42,5 +42,8 @@ namespace PlexRequests.Core.SettingModels [Obsolete("We use the CRON job now")] public int RecentlyAdded { get; set; } public string RecentlyAddedCron { get; set; } + public int FaultQueueHandler { get; set; } + public int PlexContentCacher { get; set; } + public int PlexUserChecker { get; set; } } } \ No newline at end of file diff --git a/PlexRequests.Core/SettingModels/Settings.cs b/PlexRequests.Core/SettingModels/Settings.cs index 4eb005707..dfdb4cbde 100644 --- a/PlexRequests.Core/SettingModels/Settings.cs +++ b/PlexRequests.Core/SettingModels/Settings.cs @@ -1,33 +1,33 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: Settings.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 PlexRequests.Core.SettingModels -{ - public class Settings - { - public int Id { get; set; } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: Settings.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 PlexRequests.Core.SettingModels +{ + public class Settings + { + public int Id { get; set; } + } } \ No newline at end of file diff --git a/PlexRequests.Core/SettingModels/SystemSettings.cs b/PlexRequests.Core/SettingModels/SystemSettings.cs new file mode 100644 index 000000000..883c32ba8 --- /dev/null +++ b/PlexRequests.Core/SettingModels/SystemSettings.cs @@ -0,0 +1,62 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: SystemSettings.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.ComponentModel; +using System.ComponentModel.DataAnnotations; +using PlexRequests.Core.Models; + +namespace PlexRequests.Core.SettingModels +{ + public class SystemSettings : Settings + { + public Branches Branch { get; set; } + + public StatusModel Status { get; set; } + + public List BranchDropdown { get; set; } + } + + public class BranchDropdown + { + public bool Selected { get; set; } + public string Name { get; set; } + public Branches Value { get; set; } + } + + public enum Branches + { + [Display(Name = "Stable")] + Stable, + + [Display(Name = "Early Access Preview")] + EarlyAccessPreview, + + [Display(Name = "Development")] + Dev, + } +} \ No newline at end of file diff --git a/PlexRequests.Core/SettingModels/UserManagementSettings.cs b/PlexRequests.Core/SettingModels/UserManagementSettings.cs new file mode 100644 index 000000000..768a2167c --- /dev/null +++ b/PlexRequests.Core/SettingModels/UserManagementSettings.cs @@ -0,0 +1,45 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: UserManagementSettings.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 PlexRequests.Core.SettingModels +{ + public class UserManagementSettings : Settings + { + public bool RequestMovies { get; set; } + public bool RequestTvShows { get; set; } + public bool RequestMusic { get; set; } + public bool AutoApproveMovies { get; set; } + public bool AutoApproveTvShows { get; set; } + public bool AutoApproveMusic { get; set; } + public bool ReportIssues { get; set; } + public bool UsersCanViewOnlyOwnRequests { get; set; } + public bool UsersCanViewOnlyOwnIssues { get; set; } + + // Features + public bool RecentlyAddedNotification { get; set; } + public bool RecentlyAddedNewsletter { get; set; } + } +} \ No newline at end of file diff --git a/PlexRequests.Core/Setup.cs b/PlexRequests.Core/Setup.cs index 56f3ab95e..e43809a16 100644 --- a/PlexRequests.Core/Setup.cs +++ b/PlexRequests.Core/Setup.cs @@ -50,7 +50,7 @@ namespace PlexRequests.Core Db = new DbConfiguration(new SqliteFactory()); var created = Db.CheckDb(); TableCreation.CreateTables(Db.DbConnection()); - + if (created) { CreateDefaultSettingsPage(urlBase); @@ -61,65 +61,35 @@ namespace PlexRequests.Core TableCreation.Vacuum(Db.DbConnection()); } - - // The below code is obsolete, we should use PlexRequests.Core.Migrations.MigrationRunner - var version = CheckSchema(); - if (version > 0) - { - if (version > 1899 && version <= 1900) - { - MigrateToVersion1900(); - } - - if(version > 1899 && version <= 1910) - { - MigrateToVersion1910(); - } - } + // Add the new 'running' item into the scheduled jobs so we can check if the cachers are running + Db.DbConnection().AlterTable("ScheduledJobs", "ADD", "Running", true, "INTEGER"); return Db.DbConnection().ConnectionString; } - public static string ConnectionString => Db.DbConnection().ConnectionString; - - - private int CheckSchema() - { - var productVersion = AssemblyHelper.GetProductVersion(); - var trimStatus = new Regex("[^0-9]", RegexOptions.Compiled).Replace(productVersion, string.Empty).PadRight(4, '0'); - var version = int.Parse(trimStatus); - - var connection = Db.DbConnection(); - var schema = connection.GetSchemaVersion(); - if (schema == null) - { - connection.CreateSchema(version); // Set the default. - schema = connection.GetSchemaVersion(); - } - if (version > schema.SchemaVersion) - { - Db.DbConnection().UpdateSchemaVersion(version); - schema = connection.GetSchemaVersion(); - } - version = schema.SchemaVersion; - - return version; - } - private void CreateDefaultSettingsPage(string baseUrl) { + var defaultUserSettings = new UserManagementSettings + { + RequestMovies = true, + RequestTvShows = true, + ReportIssues = true, + + }; var defaultSettings = new PlexRequestSettings { - RequireTvShowApproval = true, - RequireMovieApproval = true, SearchForMovies = true, SearchForTvShows = true, BaseUrl = baseUrl ?? string.Empty, CollectAnalyticData = true, }; - var s = new SettingsServiceV2(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), new MemoryCacheProvider())); + var ctor = new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), new MemoryCacheProvider()); + var s = new SettingsServiceV2(ctor); s.SaveSettings(defaultSettings); + var userSettings = new SettingsServiceV2(ctor); + userSettings.SaveSettings(defaultUserSettings); + var cron = (Quartz.Impl.Triggers.CronTriggerImpl)CronScheduleBuilder.WeeklyOnDayAndHourAndMinute(DayOfWeek.Friday, 7, 0).Build(); var scheduled = new ScheduledJobsSettings @@ -148,7 +118,6 @@ namespace PlexRequests.Core Task.Run(() => { CacheSonarrQualityProfiles(mc); }); Task.Run(() => { CacheCouchPotatoQualityProfiles(mc); }); // we don't need to cache sickrage profiles, those are static - // TODO: cache headphones profiles? } catch (Exception) { @@ -156,12 +125,12 @@ namespace PlexRequests.Core } } - private void CacheSonarrQualityProfiles(MemoryCacheProvider cacheProvider) + private void CacheSonarrQualityProfiles(ICacheProvider cacheProvider) { try { Log.Info("Executing GetSettings call to Sonarr for quality profiles"); - var sonarrSettingsService = new SettingsServiceV2(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), new MemoryCacheProvider())); + var sonarrSettingsService = new SettingsServiceV2(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), cacheProvider)); var sonarrSettings = sonarrSettingsService.GetSettings(); if (sonarrSettings.Enabled) { @@ -178,12 +147,12 @@ namespace PlexRequests.Core } } - private void CacheCouchPotatoQualityProfiles(MemoryCacheProvider cacheProvider) + private void CacheCouchPotatoQualityProfiles(ICacheProvider cacheProvider) { try { Log.Info("Executing GetSettings call to CouchPotato for quality profiles"); - var cpSettingsService = new SettingsServiceV2(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), new MemoryCacheProvider())); + var cpSettingsService = new SettingsServiceV2(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), cacheProvider)); var cpSettings = cpSettingsService.GetSettings(); if (cpSettings.Enabled) { @@ -199,102 +168,5 @@ namespace PlexRequests.Core Log.Error(ex, "Failed to cache CouchPotato quality profiles!"); } } - - - /// - /// Migrates to version 1.9. - /// Move the Plex auth token to the new field. - /// Reconfigure the log level - /// Set the wizard flag to true if we already have settings - /// - public void MigrateToVersion1900() - { - // Need to change the Plex Token location - var authSettings = new SettingsServiceV2(new SettingsJsonRepository(Db, new MemoryCacheProvider())); - var auth = authSettings.GetSettings(); - var plexSettings = new SettingsServiceV2(new SettingsJsonRepository(Db, new MemoryCacheProvider())); - - if (auth != null) - { - //If we have an authToken we do not need to go through the setup - if (!string.IsNullOrEmpty(auth.OldPlexAuthToken)) - { - var prServuce = new SettingsServiceV2(new SettingsJsonRepository(Db, new MemoryCacheProvider())); - var settings = prServuce.GetSettings(); - settings.Wizard = true; - prServuce.SaveSettings(settings); - } - - // Clear out the old token and save it to the new field - var currentSettings = plexSettings.GetSettings(); - if (!string.IsNullOrEmpty(auth.OldPlexAuthToken)) - { - currentSettings.PlexAuthToken = auth.OldPlexAuthToken; - plexSettings.SaveSettings(currentSettings); - - // Clear out the old value - auth.OldPlexAuthToken = string.Empty; - authSettings.SaveSettings(auth); - } - - } - - - // Set the log level - try - { - var settingsService = new SettingsServiceV2(new SettingsJsonRepository(Db, new MemoryCacheProvider())); - var logSettings = settingsService.GetSettings(); - logSettings.Level = LogLevel.Error.Ordinal; - settingsService.SaveSettings(logSettings); - - LoggingHelper.ReconfigureLogLevel(LogLevel.FromOrdinal(logSettings.Level)); - } - catch (Exception e) - { - Log.Error(e); - } - - - // Enable analytics; - try - { - - var prSettings = new SettingsServiceV2(new SettingsJsonRepository(Db, new MemoryCacheProvider())); - var settings = prSettings.GetSettings(); - settings.CollectAnalyticData = true; - var updated = prSettings.SaveSettings(settings); - - } - catch (Exception e) - { - Log.Error(e); - } - } - - /// - /// Migrates to version1910. - /// - public void MigrateToVersion1910() - { - try - { - // Get the new machine Identifier - var settings = new SettingsServiceV2(new SettingsJsonRepository(Db, new MemoryCacheProvider())); - var plex = settings.GetSettings(); - if (!string.IsNullOrEmpty(plex.PlexAuthToken)) - { - var api = new PlexApi(new ApiRequest()); - var server = api.GetServer(plex.PlexAuthToken); // Get the server info - plex.MachineIdentifier = server.Server.FirstOrDefault(x => x.AccessToken == plex.PlexAuthToken)?.MachineIdentifier; - - settings.SaveSettings(plex); // Save the new settings - } - } - catch (Exception e) - { - Log.Error(e); - } - } } } diff --git a/PlexRequests.Core/StatusChecker.cs b/PlexRequests.Core/StatusChecker.cs deleted file mode 100644 index bf9f0485e..000000000 --- a/PlexRequests.Core/StatusChecker.cs +++ /dev/null @@ -1,83 +0,0 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: StatusChecker.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; -using System.Linq; -using System.Threading.Tasks; - -using Octokit; - -using PlexRequests.Core.Models; -using PlexRequests.Helpers; - -namespace PlexRequests.Core -{ - public class StatusChecker - { - public StatusChecker() - { - Git = new GitHubClient(new ProductHeaderValue("PlexRequests-StatusChecker")); - } - private IGitHubClient Git { get; } - private const string Owner = "tidusjar"; - private const string RepoName = "PlexRequests.Net"; - - public async Task GetLatestRelease() - { - var releases = await Git.Repository.Release.GetAll(Owner, RepoName); - return releases.FirstOrDefault(); - } - - public async Task GetStatus() - { - var assemblyVersion = AssemblyHelper.GetProductVersion(); - var model = new StatusModel - { - Version = assemblyVersion, - }; - - var latestRelease = await GetLatestRelease(); - if (latestRelease == null) - { - return new StatusModel { Version = "Unknown" }; - } - var latestVersionArray = latestRelease.Name.Split(new[] { 'v' }, StringSplitOptions.RemoveEmptyEntries); - var latestVersion = latestVersionArray.Length > 1 ? latestVersionArray[1] : string.Empty; - - if (!latestVersion.Equals(assemblyVersion, StringComparison.InvariantCultureIgnoreCase)) - { - model.UpdateAvailable = true; - model.UpdateUri = latestRelease.HtmlUrl; - } - - model.ReleaseNotes = latestRelease.Body; - model.DownloadUri = latestRelease.Assets[0].BrowserDownloadUrl; - model.ReleaseTitle = latestRelease.Name; - - return model; - } - } -} \ No newline at end of file diff --git a/PlexRequests.Core/StatusChecker/AppveyorArtifactResult.cs b/PlexRequests.Core/StatusChecker/AppveyorArtifactResult.cs new file mode 100644 index 000000000..9e67262d6 --- /dev/null +++ b/PlexRequests.Core/StatusChecker/AppveyorArtifactResult.cs @@ -0,0 +1,35 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: AppveyorArtifactResult.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 PlexRequests.Core.StatusChecker +{ + public class AppveyorArtifactResult + { + public string fileName { get; set; } + public string type { get; set; } + public int size { get; set; } + } +} \ No newline at end of file diff --git a/PlexRequests.Core/StatusChecker/AppveyorBranchResult.cs b/PlexRequests.Core/StatusChecker/AppveyorBranchResult.cs new file mode 100644 index 000000000..766e5a804 --- /dev/null +++ b/PlexRequests.Core/StatusChecker/AppveyorBranchResult.cs @@ -0,0 +1,138 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: AppveyorBranchResult.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; + +namespace PlexRequests.Core.StatusChecker +{ + public class NuGetFeed + { + public string id { get; set; } + public string name { get; set; } + public bool publishingEnabled { get; set; } + public string created { get; set; } + } + + public class AccessRightDefinition + { + public string name { get; set; } + public string description { get; set; } + } + + public class AccessRight + { + public string name { get; set; } + public bool allowed { get; set; } + } + + public class RoleAce + { + public int roleId { get; set; } + public string name { get; set; } + public bool isAdmin { get; set; } + public List accessRights { get; set; } + } + + public class SecurityDescriptor + { + public List accessRightDefinitions { get; set; } + public List roleAces { get; set; } + } + + public class Project + { + public int projectId { get; set; } + public int accountId { get; set; } + public string accountName { get; set; } + public List builds { get; set; } + public string name { get; set; } + public string slug { get; set; } + public string repositoryType { get; set; } + public string repositoryScm { get; set; } + public string repositoryName { get; set; } + public string repositoryBranch { get; set; } + public bool isPrivate { get; set; } + public bool skipBranchesWithoutAppveyorYml { get; set; } + public bool enableSecureVariablesInPullRequests { get; set; } + public bool enableSecureVariablesInPullRequestsFromSameRepo { get; set; } + public bool enableDeploymentInPullRequests { get; set; } + public bool rollingBuilds { get; set; } + public bool alwaysBuildClosedPullRequests { get; set; } + public string tags { get; set; } + public NuGetFeed nuGetFeed { get; set; } + public SecurityDescriptor securityDescriptor { get; set; } + public string created { get; set; } + public string updated { get; set; } + } + + public class Job + { + public string jobId { get; set; } + public string name { get; set; } + public bool allowFailure { get; set; } + public int messagesCount { get; set; } + public int compilationMessagesCount { get; set; } + public int compilationErrorsCount { get; set; } + public int compilationWarningsCount { get; set; } + public int testsCount { get; set; } + public int passedTestsCount { get; set; } + public int failedTestsCount { get; set; } + public int artifactsCount { get; set; } + public string status { get; set; } + public string started { get; set; } + public string finished { get; set; } + public string created { get; set; } + public string updated { get; set; } + } + + public class Build + { + public int buildId { get; set; } + public List jobs { get; set; } + public int buildNumber { get; set; } + public string version { get; set; } + public string message { get; set; } + public string branch { get; set; } + public bool isTag { get; set; } + public string commitId { get; set; } + public string authorName { get; set; } + public string committerName { get; set; } + public string committed { get; set; } + public List messages { get; set; } + public string status { get; set; } + public string started { get; set; } + public string finished { get; set; } + public string created { get; set; } + public string updated { get; set; } + } + + public class AppveyorBranchResult + { + public Project project { get; set; } + public Build build { get; set; } + } +} \ No newline at end of file diff --git a/PlexRequests.Core/StatusChecker/StatusChecker.cs b/PlexRequests.Core/StatusChecker/StatusChecker.cs new file mode 100644 index 000000000..088f881ff --- /dev/null +++ b/PlexRequests.Core/StatusChecker/StatusChecker.cs @@ -0,0 +1,174 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: StatusChecker.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; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Octokit; +using PlexRequests.Api; +using PlexRequests.Core.Models; +using PlexRequests.Core.SettingModels; +using PlexRequests.Helpers; +using RestSharp; + +namespace PlexRequests.Core.StatusChecker +{ + public class StatusChecker : IStatusChecker + { + public StatusChecker(ISettingsService ss) + { + SystemSettings = ss; + Git = new GitHubClient(new ProductHeaderValue("PlexRequests-StatusChecker")); + } + + private ISettingsService SystemSettings { get; } + + private IGitHubClient Git { get; } + private const string Owner = "tidusjar"; + private const string RepoName = "PlexRequests.Net"; + private const string AppveyorApiUrl = "https://ci.appveyor.com/api"; + + private const string Api = + "48Ku58C0794nBrXra8IxWav+dc6NqgkRw+PZB3/bQwbt/D0IrnJQkgtjzo0bd6nkooLMKsC8M+Ab7jyBO+ROjY14VRuxffpDopX9r0iG/fjBl6mZVvqkm+VTDNstDtzp"; + + public async Task GetStatus() + { + var settings = await SystemSettings.GetSettingsAsync(); + var stable = settings.Branch == Branches.Stable; + + if (!stable) + { + // Early Access Preview Releases + return GetAppveyorRelease(settings.Branch); + } + + // Stable releases + return await GetLatestGithubRelease(); + } + + private async Task GetLatestGithubRelease() + { + var assemblyVersion = AssemblyHelper.GetProductVersion(); + var model = new StatusModel + { + CurrentVersion = assemblyVersion, + }; + + var releases = await Git.Repository.Release.GetAll(Owner, RepoName); + var latestRelease = releases.FirstOrDefault(); + + if (latestRelease == null) + { + return new StatusModel { NewVersion = "Unknown" }; + } + var latestVersionArray = latestRelease.Name.Split(new[] { 'v' }, StringSplitOptions.RemoveEmptyEntries); + var latestVersion = latestVersionArray.Length > 1 ? latestVersionArray[1] : string.Empty; + + if (!latestVersion.Equals(assemblyVersion, StringComparison.InvariantCultureIgnoreCase)) + { + model.UpdateAvailable = true; + model.UpdateUri = latestRelease.HtmlUrl; + model.NewVersion = latestVersion; + } + + model.ReleaseNotes = latestRelease.Body; + model.DownloadUri = latestRelease.Assets[0].BrowserDownloadUrl; + model.ReleaseTitle = latestRelease.Name; + + return model; + } + + private StatusModel GetAppveyorRelease(Branches branch) + { + var request = new ApiRequest(); + + // Get latest EAP Build + var eapBranchRequest = new RestRequest + { + Method = Method.GET + }; + + + switch (branch) + { + case Branches.Dev: + eapBranchRequest.Resource = "/projects/tidusjar/requestplex/branch/dev"; + break; + case Branches.EarlyAccessPreview: + eapBranchRequest.Resource = "/projects/tidusjar/requestplex/branch/EAP"; + break; + } + + var api = StringCipher.Decrypt(Api,"Appveyor"); + eapBranchRequest.AddHeader("Authorization", $"Bearer {api}"); + eapBranchRequest.AddHeader("Content-Type", "application/json"); + + var branchResult = request.ExecuteJson(eapBranchRequest, new Uri(AppveyorApiUrl)); + + var jobId = branchResult.build.jobs.FirstOrDefault()?.jobId ?? string.Empty; + + if (string.IsNullOrEmpty(jobId)) + { + return new StatusModel {UpdateAvailable = false}; + } + + // Get artifacts from the EAP Build + var eapAtrifactRequest = new RestRequest + { + Resource = $"/buildjobs/{jobId}/artifacts", + Method = Method.GET + }; + eapAtrifactRequest.AddHeader("Authorization", $"Bearer {api}"); + eapAtrifactRequest.AddHeader("Content-Type", "application/json"); + + var artifactResult = request.ExecuteJson>(eapAtrifactRequest, new Uri(AppveyorApiUrl)).FirstOrDefault(); + + var downloadLink = $"{AppveyorApiUrl}/buildjobs/{jobId}/artifacts/{artifactResult.fileName}"; + + var branchDisplay = EnumHelper.GetDisplayValue(branch); + var fileversion = AssemblyHelper.GetFileVersion(); + + var model = new StatusModel + { + DownloadUri = downloadLink, + ReleaseNotes = $"{branchDisplay} (See recent commits for details)", + ReleaseTitle = $"Plex Requests {branchDisplay}", + NewVersion = branchResult.build.version, + UpdateUri = downloadLink, + CurrentVersion = fileversion + }; + + if (!fileversion.Equals(branchResult.build.version, StringComparison.CurrentCultureIgnoreCase)) + { + model.UpdateAvailable = true; + } + + return model; + } + } +} \ No newline at end of file diff --git a/PlexRequests.UI/Helpers/TvSender.cs b/PlexRequests.Core/TvSender.cs similarity index 99% rename from PlexRequests.UI/Helpers/TvSender.cs rename to PlexRequests.Core/TvSender.cs index b67311d64..7ec462582 100644 --- a/PlexRequests.UI/Helpers/TvSender.cs +++ b/PlexRequests.Core/TvSender.cs @@ -24,18 +24,19 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // ************************************************************************/ #endregion + using System; using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; using NLog; using PlexRequests.Api.Interfaces; using PlexRequests.Api.Models.SickRage; using PlexRequests.Api.Models.Sonarr; using PlexRequests.Core.SettingModels; using PlexRequests.Store; -using System.Linq; -using System.Threading.Tasks; -namespace PlexRequests.UI.Helpers +namespace PlexRequests.Core { public class TvSender { diff --git a/PlexRequests.UI/Helpers/TvSenderOld.cs b/PlexRequests.Core/TvSenderOld.cs similarity index 99% rename from PlexRequests.UI/Helpers/TvSenderOld.cs rename to PlexRequests.Core/TvSenderOld.cs index ced1c81dd..b603272b1 100644 --- a/PlexRequests.UI/Helpers/TvSenderOld.cs +++ b/PlexRequests.Core/TvSenderOld.cs @@ -36,7 +36,7 @@ using PlexRequests.Api.Models.Sonarr; using PlexRequests.Core.SettingModels; using PlexRequests.Store; -namespace PlexRequests.UI.Helpers +namespace PlexRequests.Core { public class TvSenderOld { diff --git a/PlexRequests.Core/UserIdentity.cs b/PlexRequests.Core/UserIdentity.cs index 5c5f7302c..3a01146e5 100644 --- a/PlexRequests.Core/UserIdentity.cs +++ b/PlexRequests.Core/UserIdentity.cs @@ -1,38 +1,38 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: UserIdentity.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 Nancy.Security; - -namespace PlexRequests.Core -{ - public class UserIdentity : IUserIdentity - { - public string UserName { get; set; } - public IEnumerable Claims { get; set; } - } -} +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: UserIdentity.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 Nancy.Security; + +namespace PlexRequests.Core +{ + public class UserIdentity : IUserIdentity + { + public string UserName { get; set; } + public IEnumerable Claims { get; set; } + } +} diff --git a/PlexRequests.Core/UserMapper.cs b/PlexRequests.Core/UserMapper.cs index 9a0afc8de..50215093d 100644 --- a/PlexRequests.Core/UserMapper.cs +++ b/PlexRequests.Core/UserMapper.cs @@ -145,26 +145,6 @@ namespace PlexRequests.Core Repo.Delete(user); } - public Guid? CreateAdmin(string username, string password, UserProperties properties = null) - { - return CreateUser(username, password, properties); - } - - public Guid? CreatePowerUser(string username, string password, UserProperties properties = null) - { - return CreateUser(username, password, properties); - } - - public Guid? CreateRegularUser(string username, string password, UserProperties properties = null) - { - return CreateUser(username, password, properties); - } - - public IEnumerable GetAllClaims() - { - var properties = typeof(UserClaims).GetConstantsValues(); - return properties; - } public bool UpdatePassword(string username, string oldPassword, string newPassword) { @@ -207,11 +187,8 @@ namespace PlexRequests.Core public interface ICustomUserMapper { - Guid? CreateUser(string username, string password, UserProperties props); - Guid? CreateUser(string username, string password, int permissions, int features, UserProperties properties = null); - IEnumerable GetAllClaims(); IEnumerable GetUsers(); Task> GetUsersAsync(); UsersModel GetUser(Guid userId); @@ -219,9 +196,6 @@ namespace PlexRequests.Core bool DoUsersExist(); Guid? ValidateUser(string username, string password); bool UpdatePassword(string username, string oldPassword, string newPassword); - Guid? CreateAdmin(string username, string password, UserProperties properties = null); - Guid? CreatePowerUser(string username, string password, UserProperties properties = null); - Guid? CreateRegularUser(string username, string password, UserProperties properties = null); void DeleteUser(string userId); } } diff --git a/PlexRequests.Core/Users/IUserHelper.cs b/PlexRequests.Core/Users/IUserHelper.cs new file mode 100644 index 000000000..492574d47 --- /dev/null +++ b/PlexRequests.Core/Users/IUserHelper.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; +using PlexRequests.Helpers.Permissions; + +namespace PlexRequests.Core.Users +{ + public interface IUserHelper + { + IEnumerable GetUsers(); + IEnumerable GetUsersWithPermission(Permissions permission); + IEnumerable GetUsersWithFeature(Features feature); + } +} \ No newline at end of file diff --git a/PlexRequests.Core/Users/UserHelper.cs b/PlexRequests.Core/Users/UserHelper.cs new file mode 100644 index 000000000..1654e0906 --- /dev/null +++ b/PlexRequests.Core/Users/UserHelper.cs @@ -0,0 +1,159 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: UserHelper.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.Linq; +using PlexRequests.Core.Models; +using PlexRequests.Helpers; +using PlexRequests.Helpers.Permissions; +using PlexRequests.Store.Repository; + +namespace PlexRequests.Core.Users +{ + public class UserHelper : IUserHelper + { + public UserHelper(IUserRepository userRepository, IPlexUserRepository plexUsers, ISecurityExtensions security) + { + LocalUserRepository = userRepository; + PlexUserRepository = plexUsers; + Security = security; + } + + private IUserRepository LocalUserRepository { get; } + private IPlexUserRepository PlexUserRepository { get; } + private ISecurityExtensions Security { get; } + + + public IEnumerable GetUsers() + { + var model = new List(); + + var localUsers = LocalUserRepository.GetAll(); + var plexUsers = PlexUserRepository.GetAll(); + + foreach (var user in localUsers) + { + var props = ByteConverterHelper.ReturnObject(user.UserProperties); + model.Add(new UserHelperModel + { + Type = UserType.LocalUser, + Username = user.UserName, + UserAlias = props.UserAlias, + EmailAddress = props.EmailAddress, + Permissions = (Permissions)user.Permissions + }); + } + + model.AddRange(plexUsers.Select(user => new UserHelperModel + { + Type = UserType.LocalUser, + Username = user.Username, + UserAlias = user.UserAlias, + EmailAddress = user.EmailAddress, + Permissions = (Permissions)user.Permissions + })); + + return model; + } + + public IEnumerable GetUsersWithPermission(Permissions permission) + { + var model = new List(); + + var localUsers = LocalUserRepository.GetAll().ToList(); + var plexUsers = PlexUserRepository.GetAll().ToList(); + + var filteredLocal = localUsers.Where(x => ((Permissions)x.Permissions).HasFlag(permission)); + var filteredPlex = plexUsers.Where(x => ((Permissions)x.Permissions).HasFlag(permission)); + + + foreach (var user in filteredLocal) + { + var props = ByteConverterHelper.ReturnObject(user.UserProperties); + model.Add(new UserHelperModel + { + Type = UserType.LocalUser, + Username = user.UserName, + UserAlias = props.UserAlias, + EmailAddress = props.EmailAddress, + Permissions = (Permissions)user.Permissions, + Features = (Features)user.Features + }); + } + + model.AddRange(filteredPlex.Select(user => new UserHelperModel + { + Type = UserType.LocalUser, + Username = user.Username, + UserAlias = user.UserAlias, + EmailAddress = user.EmailAddress, + Permissions = (Permissions)user.Permissions, + Features = (Features)user.Features + })); + + return model; + } + + public IEnumerable GetUsersWithFeature(Features features) + { + var model = new List(); + + var localUsers = LocalUserRepository.GetAll().ToList(); + var plexUsers = PlexUserRepository.GetAll().ToList(); + + var filteredLocal = localUsers.Where(x => ((Features)x.Features).HasFlag(features)); + var filteredPlex = plexUsers.Where(x => ((Features)x.Features).HasFlag(features)); + + + foreach (var user in filteredLocal) + { + var props = ByteConverterHelper.ReturnObject(user.UserProperties); + model.Add(new UserHelperModel + { + Type = UserType.LocalUser, + Username = user.UserName, + UserAlias = props.UserAlias, + EmailAddress = props.EmailAddress, + Permissions = (Permissions)user.Permissions, + Features = (Features)user.Features + }); + } + + model.AddRange(filteredPlex.Select(user => new UserHelperModel + { + Type = UserType.LocalUser, + Username = user.Username, + UserAlias = user.UserAlias, + EmailAddress = user.EmailAddress, + Permissions = (Permissions)user.Permissions, + Features = (Features)user.Features + })); + + return model; + } + } +} \ No newline at end of file diff --git a/PlexRequests.Core.Tests/StatusCheckerTests.cs b/PlexRequests.Core/Users/UserHelperModel.cs similarity index 75% rename from PlexRequests.Core.Tests/StatusCheckerTests.cs rename to PlexRequests.Core/Users/UserHelperModel.cs index da0dd44d7..5d66fc066 100644 --- a/PlexRequests.Core.Tests/StatusCheckerTests.cs +++ b/PlexRequests.Core/Users/UserHelperModel.cs @@ -1,46 +1,42 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: AuthenticationSettingsTests.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; -using NUnit.Framework; - -namespace PlexRequests.Core.Tests -{ - [TestFixture] - public class StatusCheckerTests - { - [Test] - [Ignore("API Limit")] - public void CheckStatusTest() - { - var checker = new StatusChecker(); - var status = checker.GetStatus(); - - Assert.That(status, Is.Not.Null); - } - } -} +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: UserHelperModel.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 PlexRequests.Helpers; +using PlexRequests.Helpers.Permissions; + +namespace PlexRequests.Core.Users +{ + public class UserHelperModel + { + public string Username { get; set; } + public string UserAlias { get; set; } + public Permissions Permissions { get; set; } + public Features Features { get; set; } + public string EmailAddress { get; set; } + public UserType Type { get; set; } + } +} \ No newline at end of file diff --git a/PlexRequests.Core/Users/UserManagementHelper.cs b/PlexRequests.Core/Users/UserManagementHelper.cs new file mode 100644 index 000000000..1188a7717 --- /dev/null +++ b/PlexRequests.Core/Users/UserManagementHelper.cs @@ -0,0 +1,70 @@ +using PlexRequests.Core.SettingModels; +using PlexRequests.Helpers.Permissions; + +namespace PlexRequests.Core.Users +{ + public static class UserManagementHelper + { + + public static int GetPermissions(UserManagementSettings settings) + { + var permission = 0; + + if (settings.AutoApproveMovies) + { + permission += (int)Permissions.AutoApproveMovie; + } + if (settings.AutoApproveMusic) + { + permission += (int)Permissions.AutoApproveAlbum; + } + if (settings.AutoApproveTvShows) + { + permission += (int)Permissions.AutoApproveTv; + } + if (settings.RequestMovies) + { + permission += (int)Permissions.RequestMovie; + } + if (settings.RequestMusic) + { + permission += (int)Permissions.RequestMusic; + } + if (settings.RequestTvShows) + { + permission += (int)Permissions.RequestTvShow; + } + if (settings.ReportIssues) + { + permission += (int)Permissions.ReportIssue; + } + if (settings.UsersCanViewOnlyOwnRequests) + { + permission += (int)Permissions.UsersCanViewOnlyOwnRequests; + } + if (settings.UsersCanViewOnlyOwnIssues) + { + permission += (int)Permissions.UsersCanViewOnlyOwnIssues; + } + + + return permission; + } + + public static int GetFeatures(UserManagementSettings settings) + { + var features = 0; + + if (settings.RecentlyAddedNewsletter) + { + features += (int)Features.Newsletter; + } + if (settings.RecentlyAddedNotification) + { + features += (int)Features.RequestAddedNotification; + } + + return features; + } + } +} \ No newline at end of file diff --git a/PlexRequests.Core/packages.config b/PlexRequests.Core/packages.config index 6f3ca4a6c..e343a209e 100644 --- a/PlexRequests.Core/packages.config +++ b/PlexRequests.Core/packages.config @@ -2,11 +2,14 @@ + + + \ No newline at end of file diff --git a/PlexRequests.Helpers.Tests/AssemblyHelperTests.cs b/PlexRequests.Helpers.Tests/AssemblyHelperTests.cs index b55443e61..0f4e6b9c5 100644 --- a/PlexRequests.Helpers.Tests/AssemblyHelperTests.cs +++ b/PlexRequests.Helpers.Tests/AssemblyHelperTests.cs @@ -1,41 +1,41 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: AssemblyHelperTests.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 NUnit.Framework; - -namespace PlexRequests.Helpers.Tests -{ - [TestFixture] - public class AssemblyHelperTests - { - [Test] - public void GetReleaseVersionTest() - { - var result = AssemblyHelper.GetProductVersion(); - Assert.That(result, Is.Not.Null); - } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: AssemblyHelperTests.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 NUnit.Framework; + +namespace PlexRequests.Helpers.Tests +{ + [TestFixture] + public class AssemblyHelperTests + { + [Test] + public void GetReleaseVersionTest() + { + var result = AssemblyHelper.GetProductVersion(); + Assert.That(result, Is.Not.Null); + } + } } \ No newline at end of file diff --git a/PlexRequests.Helpers.Tests/HtmlRemoverTests.cs b/PlexRequests.Helpers.Tests/HtmlRemoverTests.cs index 6a56a20ae..85d6cc192 100644 --- a/PlexRequests.Helpers.Tests/HtmlRemoverTests.cs +++ b/PlexRequests.Helpers.Tests/HtmlRemoverTests.cs @@ -1,56 +1,56 @@ -#region Copyright - -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: HtmlRemoverTests.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 NUnit.Framework; - -namespace PlexRequests.Helpers.Tests -{ - [TestFixture] - public class HtmlRemoverTests - { - [Test] - public void RemoveHtmlBasic() - { - var html = "this is bold

para

OK!"; - var result = html.RemoveHtml(); - Assert.That(result, Is.Not.Null); - Assert.That(result, Is.EqualTo("this is bold para OK!")); - } - - [Test] - public void RemoveHtmlMoreTags() - { - // Good 'ol Ali G ;) - var html = "

\"Ali G: Rezurection\" includes every episode of Da Ali G Show with new, original introductions by star, creator/writer Sacha Baron Cohen, along with the BAFTA(R) Award-winning English episodes of Da Ali G Show which have never aired on American television and The Best of Ali G.

"; - var result = html.RemoveHtml(); - Assert.That(result, Is.Not.Null); - Assert.That(result, Is.EqualTo("\"Ali G: Rezurection\" includes every episode of Da Ali G Show with new, original introductions by star, creator/writer Sacha Baron Cohen, along with the BAFTA(R) Award-winning English episodes of Da Ali G Show which have never aired on American television and The Best of Ali G.")); - } - } +#region Copyright + +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: HtmlRemoverTests.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 NUnit.Framework; + +namespace PlexRequests.Helpers.Tests +{ + [TestFixture] + public class HtmlRemoverTests + { + [Test] + public void RemoveHtmlBasic() + { + var html = "this is bold

para

OK!"; + var result = html.RemoveHtml(); + Assert.That(result, Is.Not.Null); + Assert.That(result, Is.EqualTo("this is bold para OK!")); + } + + [Test] + public void RemoveHtmlMoreTags() + { + // Good 'ol Ali G ;) + var html = "

\"Ali G: Rezurection\" includes every episode of Da Ali G Show with new, original introductions by star, creator/writer Sacha Baron Cohen, along with the BAFTA(R) Award-winning English episodes of Da Ali G Show which have never aired on American television and The Best of Ali G.

"; + var result = html.RemoveHtml(); + Assert.That(result, Is.Not.Null); + Assert.That(result, Is.EqualTo("\"Ali G: Rezurection\" includes every episode of Da Ali G Show with new, original introductions by star, creator/writer Sacha Baron Cohen, along with the BAFTA(R) Award-winning English episodes of Da Ali G Show which have never aired on American television and The Best of Ali G.")); + } + } } \ No newline at end of file diff --git a/PlexRequests.Helpers.Tests/PasswordHasherTests.cs b/PlexRequests.Helpers.Tests/PasswordHasherTests.cs index 2ac54a547..dc34e528b 100644 --- a/PlexRequests.Helpers.Tests/PasswordHasherTests.cs +++ b/PlexRequests.Helpers.Tests/PasswordHasherTests.cs @@ -1,49 +1,49 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: AssemblyHelperTests.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 NUnit.Framework; - -namespace PlexRequests.Helpers.Tests -{ - [TestFixture] - public class PasswordHasherTests - { - [Test] - public void TestHash() - { - var password = "abcdef"; - var salt = PasswordHasher.GenerateSalt(); - var hash = PasswordHasher.ComputeHash(password, salt); - - Assert.That(hash, Is.Not.EqualTo(password)); - - var match = PasswordHasher.VerifyPassword(password, salt, hash); - - Assert.That(match, Is.True); - } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: AssemblyHelperTests.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 NUnit.Framework; + +namespace PlexRequests.Helpers.Tests +{ + [TestFixture] + public class PasswordHasherTests + { + [Test] + public void TestHash() + { + var password = "abcdef"; + var salt = PasswordHasher.GenerateSalt(); + var hash = PasswordHasher.ComputeHash(password, salt); + + Assert.That(hash, Is.Not.EqualTo(password)); + + var match = PasswordHasher.VerifyPassword(password, salt, hash); + + Assert.That(match, Is.True); + } + } } \ No newline at end of file diff --git a/PlexRequests.Helpers.Tests/Properties/AssemblyInfo.cs b/PlexRequests.Helpers.Tests/Properties/AssemblyInfo.cs index 1bebc4548..3a3229bd4 100644 --- a/PlexRequests.Helpers.Tests/Properties/AssemblyInfo.cs +++ b/PlexRequests.Helpers.Tests/Properties/AssemblyInfo.cs @@ -1,37 +1,37 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("PlexRequests.Helpers.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("PlexRequests.Helpers.Tests")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("0e6395d3-b074-49e8-898d-0eb99e507e0e")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] -[assembly: AssemblyInformationalVersionAttribute("1.0.0.0")] +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("PlexRequests.Helpers.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PlexRequests.Helpers.Tests")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("0e6395d3-b074-49e8-898d-0eb99e507e0e")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyInformationalVersionAttribute("1.0.0.0")] diff --git a/PlexRequests.Helpers.Tests/UriHelperTests.cs b/PlexRequests.Helpers.Tests/UriHelperTests.cs index cc748f95c..be69d7932 100644 --- a/PlexRequests.Helpers.Tests/UriHelperTests.cs +++ b/PlexRequests.Helpers.Tests/UriHelperTests.cs @@ -1,108 +1,108 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: UriHelperTests.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; -using System.Collections.Generic; - -using NUnit.Framework; - -namespace PlexRequests.Helpers.Tests -{ - [TestFixture] - public class UriHelperTests - { - [TestCaseSource(nameof(UriData))] - public Uri CreateUri1(string uri) - { - return uri.ReturnUri(); - } - - [Test] - public void CreateUriWithSsl() - { - var uri = "192.168.1.69"; - var result = uri.ReturnUri(8080, true); - - Assert.That(result, Is.EqualTo(new Uri("https://192.168.1.69:8080"))); - } - - [TestCaseSource(nameof(UriDataWithPort))] - public Uri CreateUri2(string uri, int port) - { - return uri.ReturnUri(port); - } - - [TestCaseSource(nameof(UriDataWithSubDir))] - public Uri CreateUriWithSubDir(string uri, int port, bool ssl, string subDir) - { - return uri.ReturnUriWithSubDir(port, ssl, subDir); - } - - private static IEnumerable UriData - { - get - { - yield return new TestCaseData("google.com").Returns(new Uri("http://google.com/")); - yield return new TestCaseData("http://google.com").Returns(new Uri("http://google.com/")); - yield return new TestCaseData("https://google.com").Returns(new Uri("https://google.com/")); - yield return new TestCaseData("192.168.1.1").Returns(new Uri("http://192.168.1.1")); - yield return new TestCaseData("0.0.0.0:5533").Returns(new Uri("http://0.0.0.0:5533")); - yield return new TestCaseData("www.google.com").Returns(new Uri("http://www.google.com/")); - yield return new TestCaseData("http://www.google.com/").Returns(new Uri("http://www.google.com/")); - yield return new TestCaseData("https://www.google.com").Returns(new Uri("https://www.google.com/")); - yield return new TestCaseData("www.google.com:443").Returns(new Uri("http://www.google.com:443/")); - yield return new TestCaseData("https://www.google.com:443").Returns(new Uri("https://www.google.com/")); - yield return new TestCaseData("http://www.google.com:443/id=2").Returns(new Uri("http://www.google.com:443/id=2")); - yield return new TestCaseData("www.google.com:4438/id=22").Returns(new Uri("http://www.google.com:4438/id=22")); - } - } - - private static IEnumerable UriDataWithPort - { - get - { - yield return new TestCaseData("www.google.com", 80).Returns(new Uri("http://www.google.com:80/")); - yield return new TestCaseData("www.google.com", 443).Returns(new Uri("http://www.google.com:443/")); - yield return new TestCaseData("http://www.google.com", 443).Returns(new Uri("http://www.google.com:443/")); - yield return new TestCaseData("https://www.google.com", 443).Returns(new Uri("https://www.google.com:443/")); - yield return new TestCaseData("http://www.google.com/id=2", 443).Returns(new Uri("http://www.google.com:443/id=2")); - yield return new TestCaseData("https://www.google.com/id=2", 443).Returns(new Uri("https://www.google.com:443/id=2")); - } - } - - private static IEnumerable UriDataWithSubDir - { - get - { - yield return new TestCaseData("www.google.com", 80, false, "test").Returns(new Uri("http://www.google.com:80/test")); - yield return new TestCaseData("www.google.com", 443, false, "test").Returns(new Uri("http://www.google.com:443/test")); - yield return new TestCaseData("http://www.google.com", 443, true, "test").Returns(new Uri("https://www.google.com:443/test")); - yield return new TestCaseData("https://www.google.com", 443, true, "test").Returns(new Uri("https://www.google.com:443/test")); - } - } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: UriHelperTests.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; +using System.Collections.Generic; + +using NUnit.Framework; + +namespace PlexRequests.Helpers.Tests +{ + [TestFixture] + public class UriHelperTests + { + [TestCaseSource(nameof(UriData))] + public Uri CreateUri1(string uri) + { + return uri.ReturnUri(); + } + + [Test] + public void CreateUriWithSsl() + { + var uri = "192.168.1.69"; + var result = uri.ReturnUri(8080, true); + + Assert.That(result, Is.EqualTo(new Uri("https://192.168.1.69:8080"))); + } + + [TestCaseSource(nameof(UriDataWithPort))] + public Uri CreateUri2(string uri, int port) + { + return uri.ReturnUri(port); + } + + [TestCaseSource(nameof(UriDataWithSubDir))] + public Uri CreateUriWithSubDir(string uri, int port, bool ssl, string subDir) + { + return uri.ReturnUriWithSubDir(port, ssl, subDir); + } + + private static IEnumerable UriData + { + get + { + yield return new TestCaseData("google.com").Returns(new Uri("http://google.com/")); + yield return new TestCaseData("http://google.com").Returns(new Uri("http://google.com/")); + yield return new TestCaseData("https://google.com").Returns(new Uri("https://google.com/")); + yield return new TestCaseData("192.168.1.1").Returns(new Uri("http://192.168.1.1")); + yield return new TestCaseData("0.0.0.0:5533").Returns(new Uri("http://0.0.0.0:5533")); + yield return new TestCaseData("www.google.com").Returns(new Uri("http://www.google.com/")); + yield return new TestCaseData("http://www.google.com/").Returns(new Uri("http://www.google.com/")); + yield return new TestCaseData("https://www.google.com").Returns(new Uri("https://www.google.com/")); + yield return new TestCaseData("www.google.com:443").Returns(new Uri("http://www.google.com:443/")); + yield return new TestCaseData("https://www.google.com:443").Returns(new Uri("https://www.google.com/")); + yield return new TestCaseData("http://www.google.com:443/id=2").Returns(new Uri("http://www.google.com:443/id=2")); + yield return new TestCaseData("www.google.com:4438/id=22").Returns(new Uri("http://www.google.com:4438/id=22")); + } + } + + private static IEnumerable UriDataWithPort + { + get + { + yield return new TestCaseData("www.google.com", 80).Returns(new Uri("http://www.google.com:80/")); + yield return new TestCaseData("www.google.com", 443).Returns(new Uri("http://www.google.com:443/")); + yield return new TestCaseData("http://www.google.com", 443).Returns(new Uri("http://www.google.com:443/")); + yield return new TestCaseData("https://www.google.com", 443).Returns(new Uri("https://www.google.com:443/")); + yield return new TestCaseData("http://www.google.com/id=2", 443).Returns(new Uri("http://www.google.com:443/id=2")); + yield return new TestCaseData("https://www.google.com/id=2", 443).Returns(new Uri("https://www.google.com:443/id=2")); + } + } + + private static IEnumerable UriDataWithSubDir + { + get + { + yield return new TestCaseData("www.google.com", 80, false, "test").Returns(new Uri("http://www.google.com:80/test")); + yield return new TestCaseData("www.google.com", 443, false, "test").Returns(new Uri("http://www.google.com:443/test")); + yield return new TestCaseData("http://www.google.com", 443, true, "test").Returns(new Uri("https://www.google.com:443/test")); + yield return new TestCaseData("https://www.google.com", 443, true, "test").Returns(new Uri("https://www.google.com:443/test")); + } + } + } } \ No newline at end of file diff --git a/PlexRequests.Helpers/AssemblyHelper.cs b/PlexRequests.Helpers/AssemblyHelper.cs index 6c450bda8..abdcfeeaf 100644 --- a/PlexRequests.Helpers/AssemblyHelper.cs +++ b/PlexRequests.Helpers/AssemblyHelper.cs @@ -1,49 +1,57 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: AssemblyHelper.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.Diagnostics; -using System.Reflection; - -namespace PlexRequests.Helpers -{ - public class AssemblyHelper - { - public static string GetAssemblyVersion() - { - var assembly = Assembly.GetExecutingAssembly(); - var fvi = FileVersionInfo.GetVersionInfo(assembly.Location); - return fvi.FileVersion; - } - - public static string GetProductVersion() - { - var assembly = Assembly.GetExecutingAssembly(); - var fvi = FileVersionInfo.GetVersionInfo(assembly.Location); - var retVersion = fvi.ProductVersion; - return retVersion; - } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: AssemblyHelper.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.Diagnostics; +using System.Reflection; + +namespace PlexRequests.Helpers +{ + public class AssemblyHelper + { + public static string GetAssemblyVersion() + { + var assembly = Assembly.GetExecutingAssembly(); + var fvi = FileVersionInfo.GetVersionInfo(assembly.Location); + return fvi.FileVersion; + } + + public static string GetProductVersion() + { + var assembly = Assembly.GetExecutingAssembly(); + var fvi = FileVersionInfo.GetVersionInfo(assembly.Location); + var retVersion = fvi.ProductVersion; + return retVersion; + } + + public static string GetFileVersion() + { + var assembly = Assembly.GetExecutingAssembly(); + var fvi = FileVersionInfo.GetVersionInfo(assembly.Location); + var retVersion = fvi.FileVersion; + return retVersion; + } + } } \ No newline at end of file diff --git a/PlexRequests.Helpers/ByteConverterHelper.cs b/PlexRequests.Helpers/ByteConverterHelper.cs index 87d569592..a18ecfce8 100644 --- a/PlexRequests.Helpers/ByteConverterHelper.cs +++ b/PlexRequests.Helpers/ByteConverterHelper.cs @@ -1,54 +1,54 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: ByteConverterHelper.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.Text; - -using Newtonsoft.Json; - -namespace PlexRequests.Helpers -{ - public class ByteConverterHelper - { - public static byte[] ReturnBytes(object obj) - { - var json = JsonConvert.SerializeObject(obj); - var bytes = Encoding.UTF8.GetBytes(json); - - return bytes; - } - - public static T ReturnObject(byte[] bytes) - { - var json = Encoding.UTF8.GetString(bytes); - var model = JsonConvert.DeserializeObject(json); - return model; - } - public static string ReturnFromBytes(byte[] bytes) - { - return Encoding.UTF8.GetString(bytes); - } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: ByteConverterHelper.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.Text; + +using Newtonsoft.Json; + +namespace PlexRequests.Helpers +{ + public class ByteConverterHelper + { + public static byte[] ReturnBytes(object obj) + { + var json = JsonConvert.SerializeObject(obj); + var bytes = Encoding.UTF8.GetBytes(json); + + return bytes; + } + + public static T ReturnObject(byte[] bytes) + { + var json = Encoding.UTF8.GetString(bytes); + var model = JsonConvert.DeserializeObject(json); + return model; + } + public static string ReturnFromBytes(byte[] bytes) + { + return Encoding.UTF8.GetString(bytes); + } + } } \ No newline at end of file diff --git a/PlexRequests.Helpers/EnumHelper.cs b/PlexRequests.Helpers/EnumHelper.cs index 051c78508..387f867e9 100644 --- a/PlexRequests.Helpers/EnumHelper.cs +++ b/PlexRequests.Helpers/EnumHelper.cs @@ -108,5 +108,10 @@ namespace PlexRequests.Helpers throw new ArgumentOutOfRangeException(nameof(name)); } + + public static int All() + { + return Enum.GetValues(typeof(T)).Cast().Sum(); + } } } \ No newline at end of file diff --git a/PlexRequests.Helpers/Exceptions/ApplicationSettingsException.cs b/PlexRequests.Helpers/Exceptions/ApplicationSettingsException.cs index 6539fc4cb..a923651d1 100644 --- a/PlexRequests.Helpers/Exceptions/ApplicationSettingsException.cs +++ b/PlexRequests.Helpers/Exceptions/ApplicationSettingsException.cs @@ -1,48 +1,48 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: ApplicationSettingsException.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; - -namespace PlexRequests.Helpers.Exceptions -{ - public class ApplicationSettingsException : Exception - { - - public ApplicationSettingsException(string message) : base(message) - { - - } - public ApplicationSettingsException(string message, Exception innerException) : base(message, innerException) - { - - } - - public ApplicationSettingsException() - { - - } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: ApplicationSettingsException.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; + +namespace PlexRequests.Helpers.Exceptions +{ + public class ApplicationSettingsException : Exception + { + + public ApplicationSettingsException(string message) : base(message) + { + + } + public ApplicationSettingsException(string message, Exception innerException) : base(message, innerException) + { + + } + + public ApplicationSettingsException() + { + + } + } } \ No newline at end of file diff --git a/PlexRequests.Helpers/HtmlRemover.cs b/PlexRequests.Helpers/HtmlRemover.cs index 43d484255..812f845a7 100644 --- a/PlexRequests.Helpers/HtmlRemover.cs +++ b/PlexRequests.Helpers/HtmlRemover.cs @@ -1,45 +1,45 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: HtmlRemover.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.Text.RegularExpressions; - -namespace PlexRequests.Helpers -{ - public static class HtmlRemover - { - public static string RemoveHtml(this string value) - { - if (string.IsNullOrEmpty(value)) - { - return string.Empty; - } - var step1 = Regex.Replace(value, @"<[^>]+>| ", "").Trim(); - var step2 = Regex.Replace(step1, @"\s{2,}", " "); - return step2; - } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: HtmlRemover.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.Text.RegularExpressions; + +namespace PlexRequests.Helpers +{ + public static class HtmlRemover + { + public static string RemoveHtml(this string value) + { + if (string.IsNullOrEmpty(value)) + { + return string.Empty; + } + var step1 = Regex.Replace(value, @"<[^>]+>| ", "").Trim(); + var step2 = Regex.Replace(step1, @"\s{2,}", " "); + return step2; + } + } } \ No newline at end of file diff --git a/PlexRequests.Helpers/ICacheProvider.cs b/PlexRequests.Helpers/ICacheProvider.cs index 00fde411b..18b051ca0 100644 --- a/PlexRequests.Helpers/ICacheProvider.cs +++ b/PlexRequests.Helpers/ICacheProvider.cs @@ -1,68 +1,68 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: ICacheProvider.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; -using System.Threading.Tasks; - -namespace PlexRequests.Helpers -{ - public interface ICacheProvider - { - /// - /// Gets the item from the cache, if the item is not present - /// then we will get that item and store it in the cache. - /// - /// Type to store in the cache - /// The key - /// The item callback. This will be called if the item is not present in the cache. - /// The amount of time we want to cache the object - /// - T GetOrSet(string key, Func itemCallback, int cacheTime = 20) where T : class; - Task GetOrSetAsync(string key, Func> itemCallback, int cacheTime = 20) where T : class; - - /// - /// Gets the specified item from the cache. - /// - /// Type to get from the cache - /// The key. - /// - T Get(string key) where T : class; - - /// - /// Set/Store the specified object in the cache - /// - /// The key. - /// The object we want to store. - /// The amount of time we want to cache the object. - void Set(string key, object data, int cacheTime = 20); - - /// - /// Removes the specified object from the cache. - /// - /// The key. - void Remove(string key); - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: ICacheProvider.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; +using System.Threading.Tasks; + +namespace PlexRequests.Helpers +{ + public interface ICacheProvider + { + /// + /// Gets the item from the cache, if the item is not present + /// then we will get that item and store it in the cache. + /// + /// Type to store in the cache + /// The key + /// The item callback. This will be called if the item is not present in the cache. + /// The amount of time we want to cache the object + /// + T GetOrSet(string key, Func itemCallback, int cacheTime = 20) where T : class; + Task GetOrSetAsync(string key, Func> itemCallback, int cacheTime = 20) where T : class; + + /// + /// Gets the specified item from the cache. + /// + /// Type to get from the cache + /// The key. + /// + T Get(string key) where T : class; + + /// + /// Set/Store the specified object in the cache + /// + /// The key. + /// The object we want to store. + /// The amount of time we want to cache the object. + void Set(string key, object data, int cacheTime = 20); + + /// + /// Removes the specified object from the cache. + /// + /// The key. + void Remove(string key); + } } \ No newline at end of file diff --git a/PlexRequests.Helpers/JsonConvertHelper.cs b/PlexRequests.Helpers/JsonConvertHelper.cs index 9762e1363..9eda9652f 100644 --- a/PlexRequests.Helpers/JsonConvertHelper.cs +++ b/PlexRequests.Helpers/JsonConvertHelper.cs @@ -1,54 +1,54 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: JsonConvertHelper.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 Newtonsoft.Json; - -namespace PlexRequests.Helpers -{ - public static class JsonConvertHelper - { - public static T[] ParseObjectToArray(object ambiguousObject) - { - var json = ambiguousObject.ToString(); - if (string.IsNullOrWhiteSpace(json)) - { - return new T[0]; // Could return null here instead. - } - if (json.TrimStart().StartsWith("[")) - { - return JsonConvert.DeserializeObject(json); - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: JsonConvertHelper.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 Newtonsoft.Json; + +namespace PlexRequests.Helpers +{ + public static class JsonConvertHelper + { + public static T[] ParseObjectToArray(object ambiguousObject) + { + var json = ambiguousObject.ToString(); + if (string.IsNullOrWhiteSpace(json)) + { + return new T[0]; // Could return null here instead. + } + if (json.TrimStart().StartsWith("[")) + { + return JsonConvert.DeserializeObject(json); + } if (json.TrimStart().Equals("{}")) { return new T[0]; - } - - return new T[1] { JsonConvert.DeserializeObject(json) }; - - } - } + } + + return new T[1] { JsonConvert.DeserializeObject(json) }; + + } + } } \ No newline at end of file diff --git a/PlexRequests.Helpers/ObjectCopier.cs b/PlexRequests.Helpers/ObjectCopier.cs index 2c4ffc2b4..2cd24808c 100644 --- a/PlexRequests.Helpers/ObjectCopier.cs +++ b/PlexRequests.Helpers/ObjectCopier.cs @@ -1,57 +1,57 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: ObjectCopier.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 Newtonsoft.Json; - -namespace PlexRequests.Helpers -{ - /// - /// Provides a method for performing a deep copy of an object. - /// Binary Serialization is used to perform the copy. - /// - public static class ObjectCopier - { - /// - /// Initialize inner objects individually - /// For example in default constructor some list property initialized with some values, - /// but in 'source' these items are cleaned - - /// without ObjectCreationHandling.Replace default constructor values will be added to result - /// - private static readonly JsonSerializerSettings Settings = new JsonSerializerSettings { ObjectCreationHandling = ObjectCreationHandling.Replace }; - - /// - /// Perform a deep Copy of the object, using Json as a serialisation method. - /// - /// The type of object being copied. - /// The object instance to copy. - /// The copied object. - public static T CloneJson(this T source) - { - // Don't serialize a null object, simply return the default for that object - return ReferenceEquals(source, null) ? default(T) : JsonConvert.DeserializeObject(JsonConvert.SerializeObject(source), Settings); - } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: ObjectCopier.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 Newtonsoft.Json; + +namespace PlexRequests.Helpers +{ + /// + /// Provides a method for performing a deep copy of an object. + /// Binary Serialization is used to perform the copy. + /// + public static class ObjectCopier + { + /// + /// Initialize inner objects individually + /// For example in default constructor some list property initialized with some values, + /// but in 'source' these items are cleaned - + /// without ObjectCreationHandling.Replace default constructor values will be added to result + /// + private static readonly JsonSerializerSettings Settings = new JsonSerializerSettings { ObjectCreationHandling = ObjectCreationHandling.Replace }; + + /// + /// Perform a deep Copy of the object, using Json as a serialisation method. + /// + /// The type of object being copied. + /// The object instance to copy. + /// The copied object. + public static T CloneJson(this T source) + { + // Don't serialize a null object, simply return the default for that object + return ReferenceEquals(source, null) ? default(T) : JsonConvert.DeserializeObject(JsonConvert.SerializeObject(source), Settings); + } + } } \ No newline at end of file diff --git a/PlexRequests.Helpers/PasswordHasher.cs b/PlexRequests.Helpers/PasswordHasher.cs index 68d797ae8..b3b4543cc 100644 --- a/PlexRequests.Helpers/PasswordHasher.cs +++ b/PlexRequests.Helpers/PasswordHasher.cs @@ -1,69 +1,69 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: PasswordHasher.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.Security.Cryptography; -namespace PlexRequests.Helpers -{ - - public static class PasswordHasher - { - // 24 = 192 bits - private const int SaltByteSize = 24; - private const int HashByteSize = 24; - private const int HasingIterationsCount = 10101; - - public static byte[] ComputeHash(string password, byte[] salt, int iterations = HasingIterationsCount, int hashByteSize = HashByteSize) - { - var hashGenerator = new Rfc2898DeriveBytes(password, salt) { IterationCount = iterations }; - return hashGenerator.GetBytes(hashByteSize); - } - - public static byte[] GenerateSalt(int saltByteSize = SaltByteSize) - { - var saltGenerator = new RNGCryptoServiceProvider(); - var salt = new byte[saltByteSize]; - saltGenerator.GetBytes(salt); - return salt; - } - - public static bool VerifyPassword(string password, byte[] passwordSalt, byte[] passwordHash) - { - var computedHash = ComputeHash(password, passwordSalt); - return AreHashesEqual(computedHash, passwordHash); - } - - //Length constant verification - prevents timing attack - private static bool AreHashesEqual(IReadOnlyList firstHash, IReadOnlyList secondHash) - { - var minHashLength = firstHash.Count <= secondHash.Count ? firstHash.Count : secondHash.Count; - var xor = firstHash.Count ^ secondHash.Count; - for (var i = 0; i < minHashLength; i++) - xor |= firstHash[i] ^ secondHash[i]; - return 0 == xor; - } - } -} +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: PasswordHasher.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.Security.Cryptography; +namespace PlexRequests.Helpers +{ + + public static class PasswordHasher + { + // 24 = 192 bits + private const int SaltByteSize = 24; + private const int HashByteSize = 24; + private const int HasingIterationsCount = 10101; + + public static byte[] ComputeHash(string password, byte[] salt, int iterations = HasingIterationsCount, int hashByteSize = HashByteSize) + { + var hashGenerator = new Rfc2898DeriveBytes(password, salt) { IterationCount = iterations }; + return hashGenerator.GetBytes(hashByteSize); + } + + public static byte[] GenerateSalt(int saltByteSize = SaltByteSize) + { + var saltGenerator = new RNGCryptoServiceProvider(); + var salt = new byte[saltByteSize]; + saltGenerator.GetBytes(salt); + return salt; + } + + public static bool VerifyPassword(string password, byte[] passwordSalt, byte[] passwordHash) + { + var computedHash = ComputeHash(password, passwordSalt); + return AreHashesEqual(computedHash, passwordHash); + } + + //Length constant verification - prevents timing attack + private static bool AreHashesEqual(IReadOnlyList firstHash, IReadOnlyList secondHash) + { + var minHashLength = firstHash.Count <= secondHash.Count ? firstHash.Count : secondHash.Count; + var xor = firstHash.Count ^ secondHash.Count; + for (var i = 0; i < minHashLength; i++) + xor |= firstHash[i] ^ secondHash[i]; + return 0 == xor; + } + } +} diff --git a/PlexRequests.Helpers/Permissions/Features.cs b/PlexRequests.Helpers/Permissions/Features.cs index a236a8d15..24a945ee3 100644 --- a/PlexRequests.Helpers/Permissions/Features.cs +++ b/PlexRequests.Helpers/Permissions/Features.cs @@ -35,8 +35,8 @@ namespace PlexRequests.Helpers.Permissions { [Display(Name = "Newsletter")] Newsletter = 1, - [Display(Name = "Recently Added Notification")] - RecentlyAddedNotification = 2, + [Display(Name = "Request Added Notification")] + RequestAddedNotification = 2, } } \ No newline at end of file diff --git a/PlexRequests.Helpers/Permissions/Permissions.cs b/PlexRequests.Helpers/Permissions/Permissions.cs index b0c28db36..74b20992e 100644 --- a/PlexRequests.Helpers/Permissions/Permissions.cs +++ b/PlexRequests.Helpers/Permissions/Permissions.cs @@ -31,6 +31,9 @@ using System.ComponentModel.DataAnnotations; namespace PlexRequests.Helpers.Permissions { [Flags] + //// + //// NOTE if any are added, make sure we change the UserManagementHelper + //// public enum Permissions { [Display(Name = "Access Administration Settings")] @@ -50,5 +53,23 @@ namespace PlexRequests.Helpers.Permissions [Display(Name = "Read Only User")] ReadOnlyUser = 32, + + [Display(Name = "Auto Approve Movie Requests")] + AutoApproveMovie = 64, + + [Display(Name = "Auto Approve TV Show Requests")] + AutoApproveTv = 128, + + [Display(Name = "Auto Approve Album Requests")] + AutoApproveAlbum = 256, + + [Display(Name = "Manage Requests")] + ManageRequests = 512, + + [Display(Name = "Users can only view their own requests")] + UsersCanViewOnlyOwnRequests = 1024, + + [Display(Name = "Users can only view their own issues")] + UsersCanViewOnlyOwnIssues = 2048 } } \ No newline at end of file diff --git a/PlexRequests.Helpers/PlexRequests.Helpers.csproj b/PlexRequests.Helpers/PlexRequests.Helpers.csproj index 90aac0c64..5563d5da5 100644 --- a/PlexRequests.Helpers/PlexRequests.Helpers.csproj +++ b/PlexRequests.Helpers/PlexRequests.Helpers.csproj @@ -90,6 +90,7 @@ + diff --git a/PlexRequests.Helpers/SerializerSettings.cs b/PlexRequests.Helpers/SerializerSettings.cs index 71cbdc0e3..00a995189 100644 --- a/PlexRequests.Helpers/SerializerSettings.cs +++ b/PlexRequests.Helpers/SerializerSettings.cs @@ -1,45 +1,45 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: SerializerSettings.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.Runtime.Serialization.Formatters; - -using Newtonsoft.Json; - -namespace PlexRequests.Helpers -{ - public static class SerializerSettings - { - - public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings - { - Formatting = Formatting.None, - TypeNameHandling = TypeNameHandling.Objects, - TypeNameAssemblyFormat = FormatterAssemblyStyle.Simple, - NullValueHandling = NullValueHandling.Ignore - }; - - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: SerializerSettings.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.Runtime.Serialization.Formatters; + +using Newtonsoft.Json; + +namespace PlexRequests.Helpers +{ + public static class SerializerSettings + { + + public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings + { + Formatting = Formatting.None, + TypeNameHandling = TypeNameHandling.Objects, + TypeNameAssemblyFormat = FormatterAssemblyStyle.Simple, + NullValueHandling = NullValueHandling.Ignore + }; + + } } \ No newline at end of file diff --git a/PlexRequests.UI/Models/SessionKeys.cs b/PlexRequests.Helpers/SessionKeys.cs similarity index 98% rename from PlexRequests.UI/Models/SessionKeys.cs rename to PlexRequests.Helpers/SessionKeys.cs index 766a84bf6..fe43a909d 100644 --- a/PlexRequests.UI/Models/SessionKeys.cs +++ b/PlexRequests.Helpers/SessionKeys.cs @@ -24,7 +24,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // ************************************************************************/ #endregion -namespace PlexRequests.UI.Models +namespace PlexRequests.Helpers { public class SessionKeys { diff --git a/PlexRequests.Helpers/StringCipher.cs b/PlexRequests.Helpers/StringCipher.cs index 8fb48e589..55455a8ae 100644 --- a/PlexRequests.Helpers/StringCipher.cs +++ b/PlexRequests.Helpers/StringCipher.cs @@ -1,145 +1,145 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: StringCipher.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; -using System.IO; -using System.Linq; -using System.Security.Cryptography; -using System.Text; - -namespace PlexRequests.Helpers -{ - public class StringCipher - { - // This constant determines the number of iterations for the password bytes generation function. - private const int DerivationIterations = 1000; - // This constant is used to determine the keysize of the encryption algorithm in bits. - // We divide this by 8 within the code below to get the equivalent number of bytes. - private const int Keysize = 256; - - /// - /// Decrypts the specified cipher text. - /// - /// The cipher text. - /// The pass phrase. - /// - public static string Decrypt(string cipherText, string passPhrase) - { - // Get the complete stream of bytes that represent: - // [32 bytes of Salt] + [32 bytes of IV] + [n bytes of CipherText] - var cipherTextBytesWithSaltAndIv = Convert.FromBase64String(cipherText); - // Get the saltbytes by extracting the first 32 bytes from the supplied cipherText bytes. - var saltStringBytes = cipherTextBytesWithSaltAndIv.Take(Keysize / 8).ToArray(); - // Get the IV bytes by extracting the next 32 bytes from the supplied cipherText bytes. - var ivStringBytes = cipherTextBytesWithSaltAndIv.Skip(Keysize / 8).Take(Keysize / 8).ToArray(); - // Get the actual cipher text bytes by removing the first 64 bytes from the cipherText string. - var cipherTextBytes = cipherTextBytesWithSaltAndIv.Skip((Keysize / 8) * 2).Take(cipherTextBytesWithSaltAndIv.Length - ((Keysize / 8) * 2)).ToArray(); - - using (var password = new Rfc2898DeriveBytes(passPhrase, saltStringBytes, DerivationIterations)) - { - var keyBytes = password.GetBytes(Keysize / 8); - using (var symmetricKey = new RijndaelManaged()) - { - symmetricKey.BlockSize = 256; - symmetricKey.Mode = CipherMode.CBC; - symmetricKey.Padding = PaddingMode.PKCS7; - using (var decryptor = symmetricKey.CreateDecryptor(keyBytes, ivStringBytes)) - { - using (var memoryStream = new MemoryStream(cipherTextBytes)) - { - using (var cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read)) - { - var plainTextBytes = new byte[cipherTextBytes.Length]; - var decryptedByteCount = cryptoStream.Read(plainTextBytes, 0, plainTextBytes.Length); - memoryStream.Close(); - cryptoStream.Close(); - return Encoding.UTF8.GetString(plainTextBytes, 0, decryptedByteCount); - } - } - } - } - } - } - - /// - /// Encrypts the specified plain text. - /// - /// The plain text. - /// The pass phrase. - /// - public static string Encrypt(string plainText, string passPhrase) - { - // Salt and IV is randomly generated each time, but is preprended to encrypted cipher text - // so that the same Salt and IV values can be used when decrypting. - var saltStringBytes = Generate256BitsOfRandomEntropy(); - var ivStringBytes = Generate256BitsOfRandomEntropy(); - var plainTextBytes = Encoding.UTF8.GetBytes(plainText); - using (var password = new Rfc2898DeriveBytes(passPhrase, saltStringBytes, DerivationIterations)) - { - var keyBytes = password.GetBytes(Keysize / 8); - using (var symmetricKey = new RijndaelManaged()) - { - symmetricKey.BlockSize = 256; - symmetricKey.Mode = CipherMode.CBC; - symmetricKey.Padding = PaddingMode.PKCS7; - using (var encryptor = symmetricKey.CreateEncryptor(keyBytes, ivStringBytes)) - { - using (var memoryStream = new MemoryStream()) - { - using (var cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write)) - { - cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length); - cryptoStream.FlushFinalBlock(); - // Create the final bytes as a concatenation of the random salt bytes, the random iv bytes and the cipher bytes. - var cipherTextBytes = saltStringBytes; - cipherTextBytes = cipherTextBytes.Concat(ivStringBytes).ToArray(); - cipherTextBytes = cipherTextBytes.Concat(memoryStream.ToArray()).ToArray(); - memoryStream.Close(); - cryptoStream.Close(); - return Convert.ToBase64String(cipherTextBytes); - } - } - } - } - } - } - - /// - /// Generate256s the bits of random entropy. - /// - /// - private static byte[] Generate256BitsOfRandomEntropy() - { - var randomBytes = new byte[32]; // 32 Bytes will give us 256 bits. - using (var rngCsp = new RNGCryptoServiceProvider()) - { - // Fill the array with cryptographically secure random bytes. - rngCsp.GetBytes(randomBytes); - } - return randomBytes; - } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: StringCipher.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; +using System.IO; +using System.Linq; +using System.Security.Cryptography; +using System.Text; + +namespace PlexRequests.Helpers +{ + public class StringCipher + { + // This constant determines the number of iterations for the password bytes generation function. + private const int DerivationIterations = 1000; + // This constant is used to determine the keysize of the encryption algorithm in bits. + // We divide this by 8 within the code below to get the equivalent number of bytes. + private const int Keysize = 256; + + /// + /// Decrypts the specified cipher text. + /// + /// The cipher text. + /// The pass phrase. + /// + public static string Decrypt(string cipherText, string passPhrase) + { + // Get the complete stream of bytes that represent: + // [32 bytes of Salt] + [32 bytes of IV] + [n bytes of CipherText] + var cipherTextBytesWithSaltAndIv = Convert.FromBase64String(cipherText); + // Get the saltbytes by extracting the first 32 bytes from the supplied cipherText bytes. + var saltStringBytes = cipherTextBytesWithSaltAndIv.Take(Keysize / 8).ToArray(); + // Get the IV bytes by extracting the next 32 bytes from the supplied cipherText bytes. + var ivStringBytes = cipherTextBytesWithSaltAndIv.Skip(Keysize / 8).Take(Keysize / 8).ToArray(); + // Get the actual cipher text bytes by removing the first 64 bytes from the cipherText string. + var cipherTextBytes = cipherTextBytesWithSaltAndIv.Skip((Keysize / 8) * 2).Take(cipherTextBytesWithSaltAndIv.Length - ((Keysize / 8) * 2)).ToArray(); + + using (var password = new Rfc2898DeriveBytes(passPhrase, saltStringBytes, DerivationIterations)) + { + var keyBytes = password.GetBytes(Keysize / 8); + using (var symmetricKey = new RijndaelManaged()) + { + symmetricKey.BlockSize = 256; + symmetricKey.Mode = CipherMode.CBC; + symmetricKey.Padding = PaddingMode.PKCS7; + using (var decryptor = symmetricKey.CreateDecryptor(keyBytes, ivStringBytes)) + { + using (var memoryStream = new MemoryStream(cipherTextBytes)) + { + using (var cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read)) + { + var plainTextBytes = new byte[cipherTextBytes.Length]; + var decryptedByteCount = cryptoStream.Read(plainTextBytes, 0, plainTextBytes.Length); + memoryStream.Close(); + cryptoStream.Close(); + return Encoding.UTF8.GetString(plainTextBytes, 0, decryptedByteCount); + } + } + } + } + } + } + + /// + /// Encrypts the specified plain text. + /// + /// The plain text. + /// The pass phrase. + /// + public static string Encrypt(string plainText, string passPhrase) + { + // Salt and IV is randomly generated each time, but is preprended to encrypted cipher text + // so that the same Salt and IV values can be used when decrypting. + var saltStringBytes = Generate256BitsOfRandomEntropy(); + var ivStringBytes = Generate256BitsOfRandomEntropy(); + var plainTextBytes = Encoding.UTF8.GetBytes(plainText); + using (var password = new Rfc2898DeriveBytes(passPhrase, saltStringBytes, DerivationIterations)) + { + var keyBytes = password.GetBytes(Keysize / 8); + using (var symmetricKey = new RijndaelManaged()) + { + symmetricKey.BlockSize = 256; + symmetricKey.Mode = CipherMode.CBC; + symmetricKey.Padding = PaddingMode.PKCS7; + using (var encryptor = symmetricKey.CreateEncryptor(keyBytes, ivStringBytes)) + { + using (var memoryStream = new MemoryStream()) + { + using (var cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write)) + { + cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length); + cryptoStream.FlushFinalBlock(); + // Create the final bytes as a concatenation of the random salt bytes, the random iv bytes and the cipher bytes. + var cipherTextBytes = saltStringBytes; + cipherTextBytes = cipherTextBytes.Concat(ivStringBytes).ToArray(); + cipherTextBytes = cipherTextBytes.Concat(memoryStream.ToArray()).ToArray(); + memoryStream.Close(); + cryptoStream.Close(); + return Convert.ToBase64String(cipherTextBytes); + } + } + } + } + } + } + + /// + /// Generate256s the bits of random entropy. + /// + /// + private static byte[] Generate256BitsOfRandomEntropy() + { + var randomBytes = new byte[32]; // 32 Bytes will give us 256 bits. + using (var rngCsp = new RNGCryptoServiceProvider()) + { + // Fill the array with cryptographically secure random bytes. + rngCsp.GetBytes(randomBytes); + } + return randomBytes; + } + } } \ No newline at end of file diff --git a/PlexRequests.Helpers/UriHelper.cs b/PlexRequests.Helpers/UriHelper.cs index 707f70436..11a4863e5 100644 --- a/PlexRequests.Helpers/UriHelper.cs +++ b/PlexRequests.Helpers/UriHelper.cs @@ -1,116 +1,116 @@ -using System; - -using PlexRequests.Helpers.Exceptions; - -namespace PlexRequests.Helpers -{ - public static class UriHelper - { - - public static Uri ReturnUri(this string val) - { - if (val == null) - { - throw new ApplicationSettingsException("The URI is null, please check your settings to make sure you have configured the applications correctly."); - } - try - { - var uri = new UriBuilder(); - - if (val.StartsWith("http://", StringComparison.Ordinal)) - { - uri = new UriBuilder(val); - } - else if (val.StartsWith("https://", StringComparison.Ordinal)) - { - uri = new UriBuilder(val); - } - else if (val.Contains(":")) - { - var split = val.Split(':', '/'); - int port; - int.TryParse(split[1], out port); - - uri = split.Length == 3 - ? new UriBuilder(Uri.UriSchemeHttp, split[0], port, "/" + split[2]) - : new UriBuilder(Uri.UriSchemeHttp, split[0], port); - } - else - { - uri = new UriBuilder(Uri.UriSchemeHttp, val); - } - - return uri.Uri; - } - catch (Exception exception) - { - throw new Exception(exception.Message, exception); - } - } - - /// - /// Returns the URI. - /// - /// The value. - /// The port. - /// if set to true [SSL]. - /// The subdir. - /// - /// The URI is null, please check your settings to make sure you have configured the applications correctly. - /// - public static Uri ReturnUri(this string val, int port, bool ssl = default(bool)) - { - if (val == null) - { - throw new ApplicationSettingsException("The URI is null, please check your settings to make sure you have configured the applications correctly."); - } - try - { - var uri = new UriBuilder(); - - if (val.StartsWith("http://", StringComparison.Ordinal)) - { - var split = val.Split('/'); - uri = split.Length >= 4 ? new UriBuilder(Uri.UriSchemeHttp, split[2], port, "/" + split[3]) : new UriBuilder(new Uri($"{val}:{port}")); - } - else if (val.StartsWith("https://", StringComparison.Ordinal)) - { - var split = val.Split('/'); - uri = split.Length >= 4 - ? new UriBuilder(Uri.UriSchemeHttps, split[2], port, "/" + split[3]) - : new UriBuilder(Uri.UriSchemeHttps, split[2], port); - } - else if(ssl) - { - uri = new UriBuilder(Uri.UriSchemeHttps, val, port); - } - else - { - uri = new UriBuilder(Uri.UriSchemeHttp, val, port); - } - - return uri.Uri; - } - catch (Exception exception) - { - throw new Exception(exception.Message, exception); - } - } - - public static Uri ReturnUriWithSubDir(this string val, int port, bool ssl, string subDir) - { - var uriBuilder = new UriBuilder(val); - if (ssl) - { - uriBuilder.Scheme = Uri.UriSchemeHttps; - } - if (!string.IsNullOrEmpty(subDir)) - { - uriBuilder.Path = subDir; - } - uriBuilder.Port = port; - - return uriBuilder.Uri; - } - } +using System; + +using PlexRequests.Helpers.Exceptions; + +namespace PlexRequests.Helpers +{ + public static class UriHelper + { + + public static Uri ReturnUri(this string val) + { + if (val == null) + { + throw new ApplicationSettingsException("The URI is null, please check your settings to make sure you have configured the applications correctly."); + } + try + { + var uri = new UriBuilder(); + + if (val.StartsWith("http://", StringComparison.Ordinal)) + { + uri = new UriBuilder(val); + } + else if (val.StartsWith("https://", StringComparison.Ordinal)) + { + uri = new UriBuilder(val); + } + else if (val.Contains(":")) + { + var split = val.Split(':', '/'); + int port; + int.TryParse(split[1], out port); + + uri = split.Length == 3 + ? new UriBuilder(Uri.UriSchemeHttp, split[0], port, "/" + split[2]) + : new UriBuilder(Uri.UriSchemeHttp, split[0], port); + } + else + { + uri = new UriBuilder(Uri.UriSchemeHttp, val); + } + + return uri.Uri; + } + catch (Exception exception) + { + throw new Exception(exception.Message, exception); + } + } + + /// + /// Returns the URI. + /// + /// The value. + /// The port. + /// if set to true [SSL]. + /// The subdir. + /// + /// The URI is null, please check your settings to make sure you have configured the applications correctly. + /// + public static Uri ReturnUri(this string val, int port, bool ssl = default(bool)) + { + if (val == null) + { + throw new ApplicationSettingsException("The URI is null, please check your settings to make sure you have configured the applications correctly."); + } + try + { + var uri = new UriBuilder(); + + if (val.StartsWith("http://", StringComparison.Ordinal)) + { + var split = val.Split('/'); + uri = split.Length >= 4 ? new UriBuilder(Uri.UriSchemeHttp, split[2], port, "/" + split[3]) : new UriBuilder(new Uri($"{val}:{port}")); + } + else if (val.StartsWith("https://", StringComparison.Ordinal)) + { + var split = val.Split('/'); + uri = split.Length >= 4 + ? new UriBuilder(Uri.UriSchemeHttps, split[2], port, "/" + split[3]) + : new UriBuilder(Uri.UriSchemeHttps, split[2], port); + } + else if(ssl) + { + uri = new UriBuilder(Uri.UriSchemeHttps, val, port); + } + else + { + uri = new UriBuilder(Uri.UriSchemeHttp, val, port); + } + + return uri.Uri; + } + catch (Exception exception) + { + throw new Exception(exception.Message, exception); + } + } + + public static Uri ReturnUriWithSubDir(this string val, int port, bool ssl, string subDir) + { + var uriBuilder = new UriBuilder(val); + if (ssl) + { + uriBuilder.Scheme = Uri.UriSchemeHttps; + } + if (!string.IsNullOrEmpty(subDir)) + { + uriBuilder.Path = subDir; + } + uriBuilder.Port = port; + + return uriBuilder.Uri; + } + } } \ No newline at end of file diff --git a/PlexRequests.Services.Tests/PlexAvailabilityCheckerTests.cs b/PlexRequests.Services.Tests/PlexAvailabilityCheckerTests.cs index 801af7509..1097bfb67 100644 --- a/PlexRequests.Services.Tests/PlexAvailabilityCheckerTests.cs +++ b/PlexRequests.Services.Tests/PlexAvailabilityCheckerTests.cs @@ -1,284 +1,284 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: PlexAvailabilityCheckerTests.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; -using System.Collections.Generic; -using System.Data; -using System.Linq; -using System.Threading.Tasks; +//#region Copyright +//// /************************************************************************ +//// Copyright (c) 2016 Jamie Rees +//// File: PlexAvailabilityCheckerTests.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; +//using System.Collections.Generic; +//using System.Data; +//using System.Linq; +//using System.Threading.Tasks; -using Moq; +//using Moq; -using NUnit.Framework; +//using NUnit.Framework; -using PlexRequests.Api.Interfaces; -using PlexRequests.Api.Models.Plex; -using PlexRequests.Core; -using PlexRequests.Core.SettingModels; -using PlexRequests.Services.Interfaces; -using PlexRequests.Helpers; -using PlexRequests.Services.Jobs; -using PlexRequests.Services.Models; -using PlexRequests.Services.Notification; -using PlexRequests.Store.Models; -using PlexRequests.Store.Repository; +//using PlexRequests.Api.Interfaces; +//using PlexRequests.Api.Models.Plex; +//using PlexRequests.Core; +//using PlexRequests.Core.SettingModels; +//using PlexRequests.Services.Interfaces; +//using PlexRequests.Helpers; +//using PlexRequests.Services.Jobs; +//using PlexRequests.Services.Models; +//using PlexRequests.Services.Notification; +//using PlexRequests.Store.Models; +//using PlexRequests.Store.Repository; -using Ploeh.AutoFixture; +//using Ploeh.AutoFixture; -namespace PlexRequests.Services.Tests -{ - [TestFixture] - public class PlexAvailabilityCheckerTests - { - public IAvailabilityChecker Checker { get; set; } - private Fixture F { get; set; } = new Fixture(); - private Mock> SettingsMock { get; set; } - private Mock> AuthMock { get; set; } - private Mock RequestMock { get; set; } - private Mock PlexMock { get; set; } - private Mock CacheMock { get; set; } - private Mock NotificationMock { get; set; } - private Mock JobRec { get; set; } - private Mock> NotifyUsers { get; set; } - private Mock> PlexEpisodes { get; set; } - private Mock Engine - { - get; - set; - } +//namespace PlexRequests.Services.Tests +//{ +// [TestFixture] +// public class PlexAvailabilityCheckerTests +// { +// public IAvailabilityChecker Checker { get; set; } +// private Fixture F { get; set; } = new Fixture(); +// private Mock> SettingsMock { get; set; } +// private Mock> AuthMock { get; set; } +// private Mock RequestMock { get; set; } +// private Mock PlexMock { get; set; } +// private Mock CacheMock { get; set; } +// private Mock NotificationMock { get; set; } +// private Mock JobRec { get; set; } +// private Mock> NotifyUsers { get; set; } +// private Mock> PlexEpisodes { get; set; } +// private Mock Engine +// { +// get; +// set; +// } - [SetUp] - public void Setup() - { - SettingsMock = new Mock>(); - AuthMock = new Mock>(); - RequestMock = new Mock(); - PlexMock = new Mock(); - NotificationMock = new Mock(); - CacheMock = new Mock(); - NotifyUsers = new Mock>(); - PlexEpisodes = new Mock>(); - JobRec = new Mock(); - Engine = new Mock(); - Checker = new PlexAvailabilityChecker(SettingsMock.Object, RequestMock.Object, PlexMock.Object, CacheMock.Object, NotificationMock.Object, JobRec.Object, NotifyUsers.Object, PlexEpisodes.Object, Engine.Object); +// [SetUp] +// public void Setup() +// { +// SettingsMock = new Mock>(); +// AuthMock = new Mock>(); +// RequestMock = new Mock(); +// PlexMock = new Mock(); +// NotificationMock = new Mock(); +// CacheMock = new Mock(); +// NotifyUsers = new Mock>(); +// PlexEpisodes = new Mock>(); +// JobRec = new Mock(); +// Engine = new Mock(); +// Checker = new PlexAvailabilityChecker(SettingsMock.Object, RequestMock.Object, PlexMock.Object, CacheMock.Object, NotificationMock.Object, JobRec.Object, NotifyUsers.Object, PlexEpisodes.Object, Engine.Object); - } +// } - [Test] - public void InvalidSettings() - { - Checker.CheckAndUpdateAll(); - PlexMock.Verify(x => x.GetLibrary(It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); - PlexMock.Verify(x => x.GetAccount(It.IsAny()), Times.Never); - PlexMock.Verify(x => x.GetLibrarySections(It.IsAny(), It.IsAny()), Times.Never); - PlexMock.Verify(x => x.GetStatus(It.IsAny(), It.IsAny()), Times.Never); - PlexMock.Verify(x => x.GetUsers(It.IsAny()), Times.Never); - } +// [Test] +// public void InvalidSettings() +// { +// Checker.CheckAndUpdateAll(); +// PlexMock.Verify(x => x.GetLibrary(It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); +// PlexMock.Verify(x => x.GetAccount(It.IsAny()), Times.Never); +// PlexMock.Verify(x => x.GetLibrarySections(It.IsAny(), It.IsAny()), Times.Never); +// PlexMock.Verify(x => x.GetStatus(It.IsAny(), It.IsAny()), Times.Never); +// PlexMock.Verify(x => x.GetUsers(It.IsAny()), Times.Never); +// } - [TestCaseSource(nameof(IsMovieAvailableTestData))] - public bool IsMovieAvailableTest(string title, string year) - { - var movies = new List - { - new PlexMovie {Title = title, ProviderId = null, ReleaseYear = year} - }; - var result = Checker.IsMovieAvailable(movies.ToArray(), "title", "2011"); +// [TestCaseSource(nameof(IsMovieAvailableTestData))] +// public bool IsMovieAvailableTest(string title, string year) +// { +// var movies = new List +// { +// new PlexMovie {Title = title, ProviderId = null, ReleaseYear = year} +// }; +// var result = Checker.IsMovieAvailable(movies.ToArray(), "title", "2011"); - return result; - } +// return result; +// } - private static IEnumerable IsMovieAvailableTestData - { - get - { - yield return new TestCaseData("title", "2011").Returns(true).SetName("IsMovieAvailable True"); - yield return new TestCaseData("title2", "2011").Returns(false).SetName("IsMovieAvailable False different title"); - yield return new TestCaseData("title", "2001").Returns(false).SetName("IsMovieAvailable False different year"); - } - } +// private static IEnumerable IsMovieAvailableTestData +// { +// get +// { +// yield return new TestCaseData("title", "2011").Returns(true).SetName("IsMovieAvailable True"); +// yield return new TestCaseData("title2", "2011").Returns(false).SetName("IsMovieAvailable False different title"); +// yield return new TestCaseData("title", "2001").Returns(false).SetName("IsMovieAvailable False different year"); +// } +// } - [TestCaseSource(nameof(IsMovieAvailableAdvancedTestData))] - public bool IsMovieAvailableAdvancedTest(string title, string year, string providerId) - { - var movies = new List - { - new PlexMovie {Title = title, ProviderId = providerId, ReleaseYear = year } - }; - var result = Checker.IsMovieAvailable(movies.ToArray(), "title", "2011", 9999.ToString()); +// [TestCaseSource(nameof(IsMovieAvailableAdvancedTestData))] +// public bool IsMovieAvailableAdvancedTest(string title, string year, string providerId) +// { +// var movies = new List +// { +// new PlexMovie {Title = title, ProviderId = providerId, ReleaseYear = year } +// }; +// var result = Checker.IsMovieAvailable(movies.ToArray(), "title", "2011", 9999.ToString()); - return result; - } +// return result; +// } - private static IEnumerable IsMovieAvailableAdvancedTestData - { - get - { - yield return new TestCaseData("title", "2011", "9999").Returns(true).SetName("Advanced IsMovieAvailable True"); - yield return new TestCaseData("title2", "2011", "99929").Returns(false).SetName("Advanced IsMovieAvailable False different title"); - yield return new TestCaseData("title", "2001", "99939").Returns(false).SetName("Advanced IsMovieAvailable False different year"); - yield return new TestCaseData("title", "2001", "44445").Returns(false).SetName("Advanced IsMovieAvailable False different providerID"); - } - } +// private static IEnumerable IsMovieAvailableAdvancedTestData +// { +// get +// { +// yield return new TestCaseData("title", "2011", "9999").Returns(true).SetName("Advanced IsMovieAvailable True"); +// yield return new TestCaseData("title2", "2011", "99929").Returns(false).SetName("Advanced IsMovieAvailable False different title"); +// yield return new TestCaseData("title", "2001", "99939").Returns(false).SetName("Advanced IsMovieAvailable False different year"); +// yield return new TestCaseData("title", "2001", "44445").Returns(false).SetName("Advanced IsMovieAvailable False different providerID"); +// } +// } - [TestCaseSource(nameof(IsTvAvailableTestData))] - public bool IsTvAvailableTest(string title, string year) - { - var tv = new List - { - new PlexTvShow {Title = title, ProviderId = null, ReleaseYear = year} - }; - var result = Checker.IsTvShowAvailable(tv.ToArray(), "title", "2011"); +// [TestCaseSource(nameof(IsTvAvailableTestData))] +// public bool IsTvAvailableTest(string title, string year) +// { +// var tv = new List +// { +// new PlexTvShow {Title = title, ProviderId = null, ReleaseYear = year} +// }; +// var result = Checker.IsTvShowAvailable(tv.ToArray(), "title", "2011"); - return result; - } +// return result; +// } - private static IEnumerable IsTvAvailableTestData - { - get - { - yield return new TestCaseData("title", "2011").Returns(true).SetName("IsTvAvailable True"); - yield return new TestCaseData("title2", "2011").Returns(false).SetName("IsTvAvailable False different title"); - yield return new TestCaseData("title", "2001").Returns(false).SetName("IsTvAvailable False different year"); - } - } +// private static IEnumerable IsTvAvailableTestData +// { +// get +// { +// yield return new TestCaseData("title", "2011").Returns(true).SetName("IsTvAvailable True"); +// yield return new TestCaseData("title2", "2011").Returns(false).SetName("IsTvAvailable False different title"); +// yield return new TestCaseData("title", "2001").Returns(false).SetName("IsTvAvailable False different year"); +// } +// } - [TestCaseSource(nameof(IsTvAvailableAdvancedTestData))] - public bool IsTvAvailableAdvancedTest(string title, string year, string providerId) - { - var movies = new List - { - new PlexTvShow {Title = title, ProviderId = providerId, ReleaseYear = year } - }; - var result = Checker.IsTvShowAvailable(movies.ToArray(), "title", "2011", 9999.ToString()); +// [TestCaseSource(nameof(IsTvAvailableAdvancedTestData))] +// public bool IsTvAvailableAdvancedTest(string title, string year, string providerId) +// { +// var movies = new List +// { +// new PlexTvShow {Title = title, ProviderId = providerId, ReleaseYear = year } +// }; +// var result = Checker.IsTvShowAvailable(movies.ToArray(), "title", "2011", 9999.ToString()); - return result; - } +// return result; +// } - private static IEnumerable IsTvAvailableAdvancedTestData - { - get - { - yield return new TestCaseData("title", "2011", "9999").Returns(true).SetName("Advanced IsTvAvailable True"); - yield return new TestCaseData("title2", "2011", "99929").Returns(false).SetName("Advanced IsTvAvailable False different title"); - yield return new TestCaseData("title", "2001", "99939").Returns(false).SetName("Advanced IsTvAvailable False different year"); - yield return new TestCaseData("title", "2001", "44445").Returns(false).SetName("Advanced IsTvAvailable False different providerID"); - } - } +// private static IEnumerable IsTvAvailableAdvancedTestData +// { +// get +// { +// yield return new TestCaseData("title", "2011", "9999").Returns(true).SetName("Advanced IsTvAvailable True"); +// yield return new TestCaseData("title2", "2011", "99929").Returns(false).SetName("Advanced IsTvAvailable False different title"); +// yield return new TestCaseData("title", "2001", "99939").Returns(false).SetName("Advanced IsTvAvailable False different year"); +// yield return new TestCaseData("title", "2001", "44445").Returns(false).SetName("Advanced IsTvAvailable False different providerID"); +// } +// } - [TestCaseSource(nameof(IsTvAvailableAdvancedSeasonsTestData))] - public bool IsTvAvailableAdvancedSeasonsTest(string title, string year, string providerId, int[] seasons) - { - var movies = new List - { - new PlexTvShow {Title = title, ProviderId = providerId, ReleaseYear = year , Seasons = seasons} - }; - var result = Checker.IsTvShowAvailable(movies.ToArray(), "title", "2011", 9999.ToString(), new[] { 1, 2, 3 }); +// [TestCaseSource(nameof(IsTvAvailableAdvancedSeasonsTestData))] +// public bool IsTvAvailableAdvancedSeasonsTest(string title, string year, string providerId, int[] seasons) +// { +// var movies = new List +// { +// new PlexTvShow {Title = title, ProviderId = providerId, ReleaseYear = year , Seasons = seasons} +// }; +// var result = Checker.IsTvShowAvailable(movies.ToArray(), "title", "2011", 9999.ToString(), new[] { 1, 2, 3 }); - return result; - } +// return result; +// } - private static IEnumerable IsTvAvailableAdvancedSeasonsTestData - { - get - { - yield return new TestCaseData("title", "2011", "9999", new[] { 1, 2, 3 }).Returns(true).SetName("Advanced IsTvSeasonsAvailable True"); - yield return new TestCaseData("title2", "2011", "99929", new[] { 5, 6 }).Returns(false).SetName("Advanced IsTvSeasonsAvailable False no seasons"); - yield return new TestCaseData("title2", "2011", "9999", new[] { 1, 6 }).Returns(true).SetName("Advanced IsTvSeasonsAvailable true one season"); - } - } +// private static IEnumerable IsTvAvailableAdvancedSeasonsTestData +// { +// get +// { +// yield return new TestCaseData("title", "2011", "9999", new[] { 1, 2, 3 }).Returns(true).SetName("Advanced IsTvSeasonsAvailable True"); +// yield return new TestCaseData("title2", "2011", "99929", new[] { 5, 6 }).Returns(false).SetName("Advanced IsTvSeasonsAvailable False no seasons"); +// yield return new TestCaseData("title2", "2011", "9999", new[] { 1, 6 }).Returns(true).SetName("Advanced IsTvSeasonsAvailable true one season"); +// } +// } - [TestCaseSource(nameof(IsEpisodeAvailableTestData))] - public bool IsEpisodeAvailableTest(string providerId, int season, int episode) - { - var expected = new List - { - new PlexEpisodes {EpisodeNumber = 1, ShowTitle = "The Flash",ProviderId = 23.ToString(), SeasonNumber = 1, EpisodeTitle = "Pilot"} - }; - PlexEpisodes.Setup(x => x.Custom(It.IsAny>>())).Returns(expected); +// [TestCaseSource(nameof(IsEpisodeAvailableTestData))] +// public bool IsEpisodeAvailableTest(string providerId, int season, int episode) +// { +// var expected = new List +// { +// new PlexEpisodes {EpisodeNumber = 1, ShowTitle = "The Flash",ProviderId = 23.ToString(), SeasonNumber = 1, EpisodeTitle = "Pilot"} +// }; +// PlexEpisodes.Setup(x => x.Custom(It.IsAny>>())).Returns(expected); - var result = Checker.IsEpisodeAvailable(providerId, season, episode); +// var result = Checker.IsEpisodeAvailable(providerId, season, episode); - return result; - } +// return result; +// } - private static IEnumerable IsEpisodeAvailableTestData - { - get - { - yield return new TestCaseData("23", 1, 1).Returns(true).SetName("IsEpisodeAvailable True S01E01"); - yield return new TestCaseData("23", 1, 2).Returns(false).SetName("IsEpisodeAvailable False S01E02"); - yield return new TestCaseData("23", 99, 99).Returns(false).SetName("IsEpisodeAvailable False S99E99"); - yield return new TestCaseData("230", 99, 99).Returns(false).SetName("IsEpisodeAvailable False Incorrect ProviderId"); - } - } +// private static IEnumerable IsEpisodeAvailableTestData +// { +// get +// { +// yield return new TestCaseData("23", 1, 1).Returns(true).SetName("IsEpisodeAvailable True S01E01"); +// yield return new TestCaseData("23", 1, 2).Returns(false).SetName("IsEpisodeAvailable False S01E02"); +// yield return new TestCaseData("23", 99, 99).Returns(false).SetName("IsEpisodeAvailable False S99E99"); +// yield return new TestCaseData("230", 99, 99).Returns(false).SetName("IsEpisodeAvailable False Incorrect ProviderId"); +// } +// } - [Test] - public void GetPlexMoviesTests() - { - var cachedMovies = F.Build().Without(x => x.Directory).CreateMany().ToList(); - cachedMovies.Add(new PlexSearch - { - Video = new List