diff --git a/PlexRequests.Core/PlexRequests.Core.csproj b/PlexRequests.Core/PlexRequests.Core.csproj index 69a511be9..44cabceeb 100644 --- a/PlexRequests.Core/PlexRequests.Core.csproj +++ b/PlexRequests.Core/PlexRequests.Core.csproj @@ -81,6 +81,7 @@ + diff --git a/PlexRequests.Core/SettingModels/AuthenticationSettings.cs b/PlexRequests.Core/SettingModels/AuthenticationSettings.cs index ae1469d4f..f95ff061d 100644 --- a/PlexRequests.Core/SettingModels/AuthenticationSettings.cs +++ b/PlexRequests.Core/SettingModels/AuthenticationSettings.cs @@ -31,10 +31,11 @@ using Newtonsoft.Json; namespace PlexRequests.Core.SettingModels { - public class AuthenticationSettings : Settings + public sealed class AuthenticationSettings : Settings { public bool UserAuthentication { get; set; } public bool UsePassword { get; set; } + [JsonProperty("PlexAuthToken")] [Obsolete("This should be migrated over into the Plex Settings and then removed in the next release")] public string OldPlexAuthToken { get; set; } diff --git a/PlexRequests.Core/SettingModels/CouchPotatoSettings.cs b/PlexRequests.Core/SettingModels/CouchPotatoSettings.cs index f22cb0b66..9be02d332 100644 --- a/PlexRequests.Core/SettingModels/CouchPotatoSettings.cs +++ b/PlexRequests.Core/SettingModels/CouchPotatoSettings.cs @@ -24,38 +24,14 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // ************************************************************************/ #endregion - -using System; -using Newtonsoft.Json; -using PlexRequests.Helpers; - namespace PlexRequests.Core.SettingModels { - public class CouchPotatoSettings : Settings + public sealed class CouchPotatoSettings : ExternalSettings { public bool Enabled { get; set; } - public string Ip { get; set; } - public int Port { get; set; } public string ApiKey { get; set; } - public bool Ssl { get; set; } public string ProfileId { get; set; } - public string SubDir { get; set; } public string Username { get; set; } public string Password { get; set; } - - [JsonIgnore] - public Uri FullUri - { - get - { - if (!string.IsNullOrEmpty(SubDir)) - { - var formattedSubDir = Ip.ReturnUriWithSubDir(Port, Ssl, SubDir); - return formattedSubDir; - } - var formatted = Ip.ReturnUri(Port, Ssl); - return formatted; - } - } } } \ No newline at end of file diff --git a/PlexRequests.Core/SettingModels/EmailNotificationSettings.cs b/PlexRequests.Core/SettingModels/EmailNotificationSettings.cs index c00342789..c0eea75dc 100644 --- a/PlexRequests.Core/SettingModels/EmailNotificationSettings.cs +++ b/PlexRequests.Core/SettingModels/EmailNotificationSettings.cs @@ -26,7 +26,7 @@ #endregion namespace PlexRequests.Core.SettingModels { - public class EmailNotificationSettings : NotificationSettings + public sealed class EmailNotificationSettings : NotificationSettings { public string EmailHost { get; set; } public string EmailPassword { get; set; } diff --git a/PlexRequests.Core/SettingModels/ExternalSettings.cs b/PlexRequests.Core/SettingModels/ExternalSettings.cs new file mode 100644 index 000000000..6a52d5609 --- /dev/null +++ b/PlexRequests.Core/SettingModels/ExternalSettings.cs @@ -0,0 +1,57 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: ExternalSettings.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 PlexRequests.Helpers; + +namespace PlexRequests.Core.SettingModels +{ + public abstract class ExternalSettings : Settings + { + public bool Ssl { get; set; } + public string SubDir { get; set; } + public string Ip { get; set; } + public int Port { get; set; } + + [JsonIgnore] + public virtual Uri FullUri + { + get + { + if (!string.IsNullOrEmpty(SubDir)) + { + var formattedSubDir = Ip.ReturnUriWithSubDir(Port, Ssl, SubDir); + return formattedSubDir; + } + var formatted = Ip.ReturnUri(Port, Ssl); + return formatted; + } + } + } +} \ No newline at end of file diff --git a/PlexRequests.Core/SettingModels/HeadphonesSettings.cs b/PlexRequests.Core/SettingModels/HeadphonesSettings.cs index 96deeb821..d283e6562 100644 --- a/PlexRequests.Core/SettingModels/HeadphonesSettings.cs +++ b/PlexRequests.Core/SettingModels/HeadphonesSettings.cs @@ -1,58 +1,34 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: CouchPotatoSettings.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 PlexRequests.Helpers; - -namespace PlexRequests.Core.SettingModels -{ - public class HeadphonesSettings : Settings - { - public bool Enabled { get; set; } - public string Ip { get; set; } - public int Port { get; set; } - public string ApiKey { get; set; } - public bool Ssl { get; set; } - public string SubDir { get; set; } - - [JsonIgnore] - public Uri FullUri - { - get - { - if (!string.IsNullOrEmpty(SubDir)) - { - var formattedSubDir = Ip.ReturnUriWithSubDir(Port, Ssl, SubDir); - return formattedSubDir; - } - var formatted = Ip.ReturnUri(Port, Ssl); - return formatted; - } - } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: CouchPotatoSettings.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 sealed class HeadphonesSettings : ExternalSettings + { + public bool Enabled { get; set; } + public string ApiKey { get; set; } + } } \ No newline at end of file diff --git a/PlexRequests.Core/SettingModels/LandingPageSettings.cs b/PlexRequests.Core/SettingModels/LandingPageSettings.cs index 81a20e9dd..5d57136e8 100644 --- a/PlexRequests.Core/SettingModels/LandingPageSettings.cs +++ b/PlexRequests.Core/SettingModels/LandingPageSettings.cs @@ -30,7 +30,7 @@ using Newtonsoft.Json; namespace PlexRequests.Core.SettingModels { - public class LandingPageSettings : Settings + public sealed class LandingPageSettings : Settings { public bool Enabled { get; set; } public bool BeforeLogin { get; set; } diff --git a/PlexRequests.Core/SettingModels/LogSettings.cs b/PlexRequests.Core/SettingModels/LogSettings.cs index bcea3127d..54250c999 100644 --- a/PlexRequests.Core/SettingModels/LogSettings.cs +++ b/PlexRequests.Core/SettingModels/LogSettings.cs @@ -1,36 +1,35 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: SickRageSettings.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 NLog; - -namespace PlexRequests.Core.SettingModels -{ - public class LogSettings : Settings - { - public int Level { get; set; } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: SickRageSettings.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 sealed class LogSettings : Settings + { + public int Level { get; set; } + } } \ No newline at end of file diff --git a/PlexRequests.Core/SettingModels/PlexRequestSettings.cs b/PlexRequests.Core/SettingModels/PlexRequestSettings.cs index 6e65951d1..95bf3988c 100644 --- a/PlexRequests.Core/SettingModels/PlexRequestSettings.cs +++ b/PlexRequests.Core/SettingModels/PlexRequestSettings.cs @@ -30,7 +30,7 @@ using System.Collections.Generic; namespace PlexRequests.Core.SettingModels { - public class PlexRequestSettings : Settings + public sealed class PlexRequestSettings : Settings { public PlexRequestSettings() { diff --git a/PlexRequests.Core/SettingModels/PlexSettings.cs b/PlexRequests.Core/SettingModels/PlexSettings.cs index 1b9d2ab54..59148f28c 100644 --- a/PlexRequests.Core/SettingModels/PlexSettings.cs +++ b/PlexRequests.Core/SettingModels/PlexSettings.cs @@ -24,36 +24,12 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // ************************************************************************/ #endregion - -using System; -using Newtonsoft.Json; -using PlexRequests.Helpers; - namespace PlexRequests.Core.SettingModels { - public class PlexSettings : Settings + public sealed class PlexSettings : ExternalSettings { - public string Ip { get; set; } - public int Port { get; set; } - public bool Ssl { get; set; } - public string SubDir { get; set; } public bool AdvancedSearch { get; set; } public string PlexAuthToken { get; set; } - - [JsonIgnore] - public Uri FullUri - { - get - { - if (!string.IsNullOrEmpty(SubDir)) - { - var formattedSubDir = Ip.ReturnUriWithSubDir(Port, Ssl, SubDir); - return formattedSubDir; - } - var formatted = Ip.ReturnUri(Port, Ssl); - return formatted; - } - } } } \ No newline at end of file diff --git a/PlexRequests.Core/SettingModels/PushBulletNotificationSettings.cs b/PlexRequests.Core/SettingModels/PushBulletNotificationSettings.cs index a8cc43ef9..7b3b59a82 100644 --- a/PlexRequests.Core/SettingModels/PushBulletNotificationSettings.cs +++ b/PlexRequests.Core/SettingModels/PushBulletNotificationSettings.cs @@ -1,9 +1,35 @@ -namespace PlexRequests.Core.SettingModels +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: PushBulletNotificationSettings.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 PushbulletNotificationSettings : NotificationSettings + public sealed class PushbulletNotificationSettings : NotificationSettings { - public bool Enabled { get; set; } public string AccessToken { get; set; } public string DeviceIdentifier { get; set; } + public bool Enabled { get; set; } } } \ No newline at end of file diff --git a/PlexRequests.Core/SettingModels/PushoverNotificationSettings.cs b/PlexRequests.Core/SettingModels/PushoverNotificationSettings.cs index 87772ffa2..0c3e0b976 100644 --- a/PlexRequests.Core/SettingModels/PushoverNotificationSettings.cs +++ b/PlexRequests.Core/SettingModels/PushoverNotificationSettings.cs @@ -1,9 +1,35 @@ -namespace PlexRequests.Core.SettingModels +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: PushoverNotificationSettings.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 PushoverNotificationSettings : NotificationSettings + public sealed class PushoverNotificationSettings : NotificationSettings { - public bool Enabled { get; set; } public string AccessToken { get; set; } + public bool Enabled { get; set; } public string UserToken { get; set; } } } \ No newline at end of file diff --git a/PlexRequests.Core/SettingModels/ScheduledJobsSettings.cs b/PlexRequests.Core/SettingModels/ScheduledJobsSettings.cs index 6d895f6ef..1600a678c 100644 --- a/PlexRequests.Core/SettingModels/ScheduledJobsSettings.cs +++ b/PlexRequests.Core/SettingModels/ScheduledJobsSettings.cs @@ -26,7 +26,7 @@ #endregion namespace PlexRequests.Core.SettingModels { - public class ScheduledJobsSettings : Settings + public sealed class ScheduledJobsSettings : Settings { public ScheduledJobsSettings() { diff --git a/PlexRequests.Core/SettingModels/SickRageSettings.cs b/PlexRequests.Core/SettingModels/SickRageSettings.cs index d7c734667..b2f011755 100644 --- a/PlexRequests.Core/SettingModels/SickRageSettings.cs +++ b/PlexRequests.Core/SettingModels/SickRageSettings.cs @@ -1,77 +1,50 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: SickRageSettings.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 PlexRequests.Helpers; -using System.Collections.Generic; - -namespace PlexRequests.Core.SettingModels -{ - public class SickRageSettings : Settings - { - public bool Enabled { get; set; } - public string Ip { get; set; } - public int Port { get; set; } - public string ApiKey { get; set; } - public string QualityProfile { get; set; } - public bool Ssl { get; set; } - public string SubDir { get; set; } - public Dictionary Qualities - { - get - { - return new Dictionary() { - { "default", "Use Deafult" }, - { "sdtv", "SD TV" }, - { "sddvd", "SD DVD" }, - { "hdtv", "HD TV" }, - { "rawhdtv", "Raw HD TV" }, - { "hdwebdl", "HD Web DL" }, - { "fullhdwebdl", "Full HD Web DL" }, - { "hdbluray", "HD Bluray" }, - { "fullhdbluray", "Full HD Bluray" } - }; - } - } - - [JsonIgnore] - public Uri FullUri - { - get - { - if (!string.IsNullOrEmpty(SubDir)) - { - var formattedSubDir = Ip.ReturnUriWithSubDir(Port, Ssl, SubDir); - return formattedSubDir; - } - var formatted = Ip.ReturnUri(Port, Ssl); - return formatted; - } - } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: SickRageSettings.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.SettingModels +{ + public sealed class SickRageSettings : ExternalSettings + { + public bool Enabled { get; set; } + public string ApiKey { get; set; } + public string QualityProfile { get; set; } + + public Dictionary Qualities => new Dictionary + { + { "default", "Use Deafult" }, + { "sdtv", "SD TV" }, + { "sddvd", "SD DVD" }, + { "hdtv", "HD TV" }, + { "rawhdtv", "Raw HD TV" }, + { "hdwebdl", "HD Web DL" }, + { "fullhdwebdl", "Full HD Web DL" }, + { "hdbluray", "HD Bluray" }, + { "fullhdbluray", "Full HD Bluray" } + }; + } } \ No newline at end of file diff --git a/PlexRequests.Core/SettingModels/SlackNotificationSettings.cs b/PlexRequests.Core/SettingModels/SlackNotificationSettings.cs index 93562e8a1..8e529d618 100644 --- a/PlexRequests.Core/SettingModels/SlackNotificationSettings.cs +++ b/PlexRequests.Core/SettingModels/SlackNotificationSettings.cs @@ -4,7 +4,7 @@ using Newtonsoft.Json; namespace PlexRequests.Core.SettingModels { - public class SlackNotificationSettings : NotificationSettings + public sealed class SlackNotificationSettings : NotificationSettings { public bool Enabled { get; set; } public string WebhookUrl { get; set; } diff --git a/PlexRequests.Core/SettingModels/SonarrSettings.cs b/PlexRequests.Core/SettingModels/SonarrSettings.cs index 3c680e0e5..5b99b8ac2 100644 --- a/PlexRequests.Core/SettingModels/SonarrSettings.cs +++ b/PlexRequests.Core/SettingModels/SonarrSettings.cs @@ -1,61 +1,38 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: SonarrSettings.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 PlexRequests.Helpers; - -namespace PlexRequests.Core.SettingModels -{ - public class SonarrSettings : Settings - { - public bool Enabled { get; set; } - public string Ip { get; set; } - public int Port { get; set; } - public string ApiKey { get; set; } - public string QualityProfile { get; set; } - public bool SeasonFolders { get; set; } - public string RootPath { get; set; } - public bool Ssl { get; set; } - public string SubDir { get; set; } - - [JsonIgnore] - public Uri FullUri - { - get - { - if (!string.IsNullOrEmpty(SubDir)) - { - var formattedSubDir = Ip.ReturnUriWithSubDir(Port, Ssl, SubDir); - return formattedSubDir; - } - var formatted = Ip.ReturnUri(Port, Ssl); - return formatted; - } - } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: SonarrSettings.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 sealed class SonarrSettings : ExternalSettings + { + public bool Enabled { get; set; } + public string ApiKey { get; set; } + public string QualityProfile { get; set; } + public bool SeasonFolders { get; set; } + public string RootPath { get; set; } + + } } \ No newline at end of file diff --git a/PlexRequests.Core/SettingsServiceV2.cs b/PlexRequests.Core/SettingsServiceV2.cs index 3f422c70c..a18677eec 100644 --- a/PlexRequests.Core/SettingsServiceV2.cs +++ b/PlexRequests.Core/SettingsServiceV2.cs @@ -30,7 +30,6 @@ using Newtonsoft.Json; using PlexRequests.Core.SettingModels; using PlexRequests.Helpers; -using PlexRequests.Store; using PlexRequests.Store.Models; using PlexRequests.Store.Repository; @@ -46,8 +45,8 @@ namespace PlexRequests.Core EntityName = typeof(T).Name; } - private ISettingsRepository Repo { get; set; } - private string EntityName { get; set; } + private ISettingsRepository Repo { get; } + private string EntityName { get; } public T GetSettings() { @@ -78,7 +77,7 @@ namespace PlexRequests.Core public bool SaveSettings(T model) { var entity = Repo.Get(EntityName); - + if (entity == null) { var newEntity = model; diff --git a/PlexRequests.UI/Modules/AdminModule.cs b/PlexRequests.UI/Modules/AdminModule.cs index 5a127337e..69cdb5b9d 100644 --- a/PlexRequests.UI/Modules/AdminModule.cs +++ b/PlexRequests.UI/Modules/AdminModule.cs @@ -171,7 +171,7 @@ namespace PlexRequests.UI.Modules Post["/sonarrprofiles"] = _ => GetSonarrQualityProfiles(); Post["/cpprofiles", true] = async (x,ct) => await GetCpProfiles(); - Post["/cpapikey", true] = async (x,ct) => await GetCpApiKey(); + Post["/cpapikey"] = x => GetCpApiKey(); Get["/emailnotification"] = _ => EmailNotifications(); Post["/emailnotification"] = _ => SaveEmailNotifications(); @@ -362,6 +362,7 @@ namespace PlexRequests.UI.Modules return Response.AsJson(valid.SendJsonError()); } + couchPotatoSettings.ApiKey = couchPotatoSettings.ApiKey.Trim(); var result = CpService.SaveSettings(couchPotatoSettings); return Response.AsJson(result ? new JsonResponseModel { Result = true, Message = "Successfully Updated the Settings for CouchPotato!" } @@ -413,6 +414,7 @@ namespace PlexRequests.UI.Modules { return Response.AsJson(new JsonResponseModel { Result = false, Message = "SickRage is enabled, we cannot enable Sonarr and SickRage" }); } + sonarrSettings.ApiKey = sonarrSettings.ApiKey.Trim(); var result = SonarrService.SaveSettings(sonarrSettings); return Response.AsJson(result @@ -442,6 +444,7 @@ namespace PlexRequests.UI.Modules { return Response.AsJson(new JsonResponseModel { Result = false, Message = "Sonarr is enabled, we cannot enable Sonarr and SickRage" }); } + sickRageSettings.ApiKey = sickRageSettings.ApiKey.Trim(); var result = SickRageService.SaveSettings(sickRageSettings); return Response.AsJson(result @@ -697,7 +700,7 @@ namespace PlexRequests.UI.Modules return Response.AsJson(profiles); } - private async Task GetCpApiKey() + private Response GetCpApiKey() { var settings = this.Bind(); @@ -767,7 +770,7 @@ namespace PlexRequests.UI.Modules Log.Info("Error validating Headphones settings, message: {0}", error.Message); return Response.AsJson(error); } - + settings.ApiKey = settings.ApiKey.Trim(); var result = HeadphonesService.SaveSettings(settings); Log.Info("Saved headphones settings, result: {0}", result);