From 4fb3d9915338a2992d74e7f552885500401e38f5 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Wed, 11 Apr 2018 20:52:58 +0200 Subject: [PATCH] Fixed: Updated AnimeTosho url. closes #2501 --- .../121_update_animetosho_urlFixture.cs | 41 +++++++++++++++++++ .../NzbDrone.Core.Test.csproj | 1 + .../Migration/121_update_animetosho_url.cs | 22 ++++++++++ src/NzbDrone.Core/Indexers/Newznab/Newznab.cs | 2 +- src/NzbDrone.Core/Indexers/Torznab/Torznab.cs | 2 +- src/NzbDrone.Core/NzbDrone.Core.csproj | 1 + 6 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 src/NzbDrone.Core.Test/Datastore/Migration/121_update_animetosho_urlFixture.cs create mode 100644 src/NzbDrone.Core/Datastore/Migration/121_update_animetosho_url.cs diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/121_update_animetosho_urlFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/121_update_animetosho_urlFixture.cs new file mode 100644 index 000000000..33bdddddd --- /dev/null +++ b/src/NzbDrone.Core.Test/Datastore/Migration/121_update_animetosho_urlFixture.cs @@ -0,0 +1,41 @@ +using System.Linq; +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Common.Serializer; +using NzbDrone.Core.Datastore.Migration; +using NzbDrone.Core.Test.Framework; + +namespace NzbDrone.Core.Test.Datastore.Migration +{ + [TestFixture] + public class update_animetosho_urlFixture : MigrationTest + { + [TestCase("Newznab", "https://animetosho.org")] + [TestCase("Newznab", "http://animetosho.org")] + [TestCase("Torznab", "https://animetosho.org")] + [TestCase("Torznab", "http://animetosho.org")] + public void should_replace_old_url(string impl, string baseUrl) + { + var db = WithMigrationTestDb(c => + { + c.Insert.IntoTable("Indexers").Row(new + { + Name = "AnimeTosho", + Implementation = impl, + Settings = new NewznabSettings121 + { + BaseUrl = baseUrl, + ApiPath = "/feed/nabapi" + + }.ToJson(), + ConfigContract = impl + "Settings" + }); + }); + + var items = db.Query("SELECT * FROM Indexers"); + + items.Should().HaveCount(1); + items.First().Settings.ToObject().BaseUrl.Should().Be(baseUrl.Replace("animetosho", "feed.animetosho")); + } + } +} diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index ff8bc21a9..78dafba84 100644 --- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -148,6 +148,7 @@ + diff --git a/src/NzbDrone.Core/Datastore/Migration/121_update_animetosho_url.cs b/src/NzbDrone.Core/Datastore/Migration/121_update_animetosho_url.cs new file mode 100644 index 000000000..1a91ded75 --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/121_update_animetosho_url.cs @@ -0,0 +1,22 @@ +using FluentMigrator; +using Newtonsoft.Json.Linq; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(121)] + public class update_animetosho_url : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Execute.Sql("UPDATE Indexers SET Settings = Replace(Replace(Settings, '//animetosho.org', '//feed.animetosho.org'), '/feed/nabapi', '/nabapi') WHERE (Implementation = 'Newznab' OR Implementation = 'Torznab') AND Settings LIKE '%animetosho%';"); + } + } + + public class NewznabSettings121 + { + public string BaseUrl { get; set; } + + public string ApiPath { get; set; } + } +} diff --git a/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs b/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs index 7b87992b8..79c40b997 100644 --- a/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs +++ b/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs @@ -52,7 +52,7 @@ namespace NzbDrone.Core.Indexers.Newznab yield return GetDefinition("PFmonkey", GetSettings("https://www.pfmonkey.com")); yield return GetDefinition("SimplyNZBs", GetSettings("https://simplynzbs.com")); yield return GetDefinition("Usenet Crawler", GetSettings("https://www.usenet-crawler.com")); - yield return GetDefinition("AnimeTosho Usenet", GetSettings("https://animetosho.org", apiPath: @"/feed/nabapi", categories: new int[0], animeCategories: new[] { 5070 })); + yield return GetDefinition("AnimeTosho Usenet", GetSettings("https://feed.animetosho.org", apiPath: @"/nabapi", categories: new int[0], animeCategories: new[] { 5070 })); } } diff --git a/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs b/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs index bb9c4c3de..a671b4093 100644 --- a/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs +++ b/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs @@ -40,7 +40,7 @@ namespace NzbDrone.Core.Indexers.Torznab get { yield return GetDefinition("HD4Free.xyz", GetSettings("http://hd4free.xyz")); - yield return GetDefinition("AnimeTosho Torrents", GetSettings("https://animetosho.org", apiPath: @"/feed/nabapi", categories: new int[0], animeCategories: new[] { 5070 })); + yield return GetDefinition("AnimeTosho Torrents", GetSettings("https://feed.animetosho.org", apiPath: @"/nabapi", categories: new int[0], animeCategories: new[] { 5070 })); yield return GetDefinition("Nyaa Pantsu", GetSettings("https://nyaa.pantsu.cat", apiPath: @"/feed/torznab", categories: new int[0], animeCategories: new[] { 5070 })); } } diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index 44a26f93b..97a008f01 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -298,6 +298,7 @@ +