diff --git a/PlexRequests.Api.Models/PlexRequests.Api.Models.csproj b/PlexRequests.Api.Models/PlexRequests.Api.Models.csproj index fee0b033c..402cdd22a 100644 --- a/PlexRequests.Api.Models/PlexRequests.Api.Models.csproj +++ b/PlexRequests.Api.Models/PlexRequests.Api.Models.csproj @@ -61,6 +61,7 @@ + diff --git a/PlexRequests.Api.Models/Tv/TVMazeShow.cs b/PlexRequests.Api.Models/Tv/TVMazeShow.cs new file mode 100644 index 000000000..165658602 --- /dev/null +++ b/PlexRequests.Api.Models/Tv/TVMazeShow.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; + +namespace PlexRequests.Api.Models.Tv +{ + public class TvMazeShow + { + public int id { get; set; } + public string url { get; set; } + public string name { get; set; } + public string type { get; set; } + public string language { get; set; } + public List genres { get; set; } + public string status { get; set; } + public int runtime { get; set; } + public string premiered { get; set; } + public Schedule schedule { get; set; } + public Rating rating { get; set; } + public int weight { get; set; } + public Network network { get; set; } + public object webChannel { get; set; } + public Externals externals { get; set; } + public Image image { get; set; } + public string summary { get; set; } + public int updated { get; set; } + public Links _links { get; set; } + } +} \ No newline at end of file diff --git a/PlexRequests.Api/TvMazeApi.cs b/PlexRequests.Api/TvMazeApi.cs index 6af8c51a2..5f74ea7f2 100644 --- a/PlexRequests.Api/TvMazeApi.cs +++ b/PlexRequests.Api/TvMazeApi.cs @@ -56,5 +56,18 @@ namespace PlexRequests.Api return Api.Execute>(request, new Uri(Uri)); } + public TvMazeShow ShowLookup(int showId) + { + var request = new RestRequest + { + Method = Method.GET, + Resource = "shows/{id}" + }; + request.AddUrlSegment("id", showId.ToString()); + request.AddHeader("Content-Type", "application/json"); + + return Api.Execute(request, new Uri(Uri)); + } + } } \ No newline at end of file diff --git a/PlexRequests.Api/TvMazeBase.cs b/PlexRequests.Api/TvMazeBase.cs index 1526603bc..d4eddefee 100644 --- a/PlexRequests.Api/TvMazeBase.cs +++ b/PlexRequests.Api/TvMazeBase.cs @@ -28,6 +28,6 @@ namespace PlexRequests.Api { public class TvMazeBase { - public string Uri = "http://api.tvmaze.com"; + protected string Uri = "http://api.tvmaze.com"; } } \ No newline at end of file diff --git a/PlexRequests.Core.Tests/StatusCheckerTests.cs b/PlexRequests.Core.Tests/StatusCheckerTests.cs index e45b4dcab..da0dd44d7 100644 --- a/PlexRequests.Core.Tests/StatusCheckerTests.cs +++ b/PlexRequests.Core.Tests/StatusCheckerTests.cs @@ -34,6 +34,7 @@ namespace PlexRequests.Core.Tests public class StatusCheckerTests { [Test] + [Ignore("API Limit")] public void CheckStatusTest() { var checker = new StatusChecker(); @@ -42,4 +43,4 @@ namespace PlexRequests.Core.Tests Assert.That(status, Is.Not.Null); } } -} \ No newline at end of file +} diff --git a/PlexRequests.Core/SettingModels/CouchPotatoSettings.cs b/PlexRequests.Core/SettingModels/CouchPotatoSettings.cs index 9b3d9b385..0c4ccd06f 100644 --- a/PlexRequests.Core/SettingModels/CouchPotatoSettings.cs +++ b/PlexRequests.Core/SettingModels/CouchPotatoSettings.cs @@ -36,13 +36,14 @@ namespace PlexRequests.Core.SettingModels public string Ip { get; set; } public int Port { get; set; } public string ApiKey { get; set; } + public bool Ssl { get; set; } [JsonIgnore] public Uri FullUri { get { - var formatted = Ip.ReturnUri(Port); + var formatted = Ip.ReturnUri(Port, Ssl); return formatted; } } diff --git a/PlexRequests.Core/SettingModels/SonarrSettings.cs b/PlexRequests.Core/SettingModels/SonarrSettings.cs index 4441d48d2..15f486d37 100644 --- a/PlexRequests.Core/SettingModels/SonarrSettings.cs +++ b/PlexRequests.Core/SettingModels/SonarrSettings.cs @@ -39,13 +39,14 @@ namespace PlexRequests.Core.SettingModels public string QualityProfile { get; set; } public bool SeasonFolders { get; set; } public string RootPath { get; set; } + public bool Ssl { get; set; } [JsonIgnore] public Uri FullUri { get { - var formatted = Ip.ReturnUri(Port); + var formatted = Ip.ReturnUri(Port, Ssl); return formatted; } } diff --git a/PlexRequests.Helpers.Tests/HtmlRemoverTests.cs b/PlexRequests.Helpers.Tests/HtmlRemoverTests.cs new file mode 100644 index 000000000..6a56a20ae --- /dev/null +++ b/PlexRequests.Helpers.Tests/HtmlRemoverTests.cs @@ -0,0 +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.")); + } + } +} \ No newline at end of file diff --git a/PlexRequests.Helpers.Tests/PlexRequests.Helpers.Tests.csproj b/PlexRequests.Helpers.Tests/PlexRequests.Helpers.Tests.csproj index 54af6aebe..4bacd1b68 100644 --- a/PlexRequests.Helpers.Tests/PlexRequests.Helpers.Tests.csproj +++ b/PlexRequests.Helpers.Tests/PlexRequests.Helpers.Tests.csproj @@ -70,6 +70,7 @@ + diff --git a/PlexRequests.Helpers/HtmlRemover.cs b/PlexRequests.Helpers/HtmlRemover.cs new file mode 100644 index 000000000..64d23a6de --- /dev/null +++ b/PlexRequests.Helpers/HtmlRemover.cs @@ -0,0 +1,41 @@ +#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) + { + 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/PlexRequests.Helpers.csproj b/PlexRequests.Helpers/PlexRequests.Helpers.csproj index 04d967f00..35d56a192 100644 --- a/PlexRequests.Helpers/PlexRequests.Helpers.csproj +++ b/PlexRequests.Helpers/PlexRequests.Helpers.csproj @@ -48,6 +48,7 @@ + diff --git a/PlexRequests.Services.Tests/PlexAvailabilityCheckerTests.cs b/PlexRequests.Services.Tests/PlexAvailabilityCheckerTests.cs index 0a1a157c0..117157927 100644 --- a/PlexRequests.Services.Tests/PlexAvailabilityCheckerTests.cs +++ b/PlexRequests.Services.Tests/PlexAvailabilityCheckerTests.cs @@ -55,7 +55,7 @@ namespace PlexRequests.Services.Tests var plexMock = new Mock(); Checker = new PlexAvailabilityChecker(settingsMock.Object, authMock.Object, requestMock.Object, plexMock.Object); - Assert.Throws(() => Checker.IsAvailable("title"), "We should be throwing an exception since we cannot talk to the services."); + Assert.Throws(() => Checker.IsAvailable("title", "2013"), "We should be throwing an exception since we cannot talk to the services."); } [Test] @@ -66,7 +66,7 @@ namespace PlexRequests.Services.Tests var requestMock = new Mock(); var plexMock = new Mock(); - var searchResult = new PlexSearch {Video = new List