Fixed: Updated AnimeTosho url.

closes #2501
This commit is contained in:
Taloth Saldono 2018-04-11 20:52:58 +02:00
parent a29f133e5d
commit 4fb3d99153
6 changed files with 67 additions and 2 deletions

View File

@ -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<update_animetosho_url>
{
[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<IndexerDefinition90>("SELECT * FROM Indexers");
items.Should().HaveCount(1);
items.First().Settings.ToObject<NewznabSettings121>().BaseUrl.Should().Be(baseUrl.Replace("animetosho", "feed.animetosho"));
}
}
}

View File

@ -148,6 +148,7 @@
<Compile Include="Datastore\Migration\079_dedupe_tagsFixture.cs" /> <Compile Include="Datastore\Migration\079_dedupe_tagsFixture.cs" />
<Compile Include="Datastore\Migration\075_force_lib_updateFixture.cs" /> <Compile Include="Datastore\Migration\075_force_lib_updateFixture.cs" />
<Compile Include="Datastore\Migration\090_update_kickass_urlFixture.cs" /> <Compile Include="Datastore\Migration\090_update_kickass_urlFixture.cs" />
<Compile Include="Datastore\Migration\121_update_animetosho_urlFixture.cs" />
<Compile Include="Datastore\ObjectDatabaseFixture.cs" /> <Compile Include="Datastore\ObjectDatabaseFixture.cs" />
<Compile Include="Datastore\PagingSpecExtensionsTests\PagingOffsetFixture.cs" /> <Compile Include="Datastore\PagingSpecExtensionsTests\PagingOffsetFixture.cs" />
<Compile Include="Datastore\PagingSpecExtensionsTests\ToSortDirectionFixture.cs" /> <Compile Include="Datastore\PagingSpecExtensionsTests\ToSortDirectionFixture.cs" />

View File

@ -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; }
}
}

View File

@ -52,7 +52,7 @@ namespace NzbDrone.Core.Indexers.Newznab
yield return GetDefinition("PFmonkey", GetSettings("https://www.pfmonkey.com")); yield return GetDefinition("PFmonkey", GetSettings("https://www.pfmonkey.com"));
yield return GetDefinition("SimplyNZBs", GetSettings("https://simplynzbs.com")); yield return GetDefinition("SimplyNZBs", GetSettings("https://simplynzbs.com"));
yield return GetDefinition("Usenet Crawler", GetSettings("https://www.usenet-crawler.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 }));
} }
} }

View File

@ -40,7 +40,7 @@ namespace NzbDrone.Core.Indexers.Torznab
get get
{ {
yield return GetDefinition("HD4Free.xyz", GetSettings("http://hd4free.xyz")); 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 })); yield return GetDefinition("Nyaa Pantsu", GetSettings("https://nyaa.pantsu.cat", apiPath: @"/feed/torznab", categories: new int[0], animeCategories: new[] { 5070 }));
} }
} }

View File

@ -298,6 +298,7 @@
<Compile Include="Datastore\Migration\105_rename_torrent_downloadstation.cs" /> <Compile Include="Datastore\Migration\105_rename_torrent_downloadstation.cs" />
<Compile Include="Datastore\Migration\111_create_language_profiles.cs" /> <Compile Include="Datastore\Migration\111_create_language_profiles.cs" />
<Compile Include="Datastore\Migration\115_add_downloadclient_status.cs" /> <Compile Include="Datastore\Migration\115_add_downloadclient_status.cs" />
<Compile Include="Datastore\Migration\121_update_animetosho_url.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationContext.cs" /> <Compile Include="Datastore\Migration\Framework\MigrationContext.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationController.cs" /> <Compile Include="Datastore\Migration\Framework\MigrationController.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationDbFactory.cs" /> <Compile Include="Datastore\Migration\Framework\MigrationDbFactory.cs" />