mirror of
https://github.com/Prowlarr/Prowlarr
synced 2025-12-06 00:22:31 +01:00
Fixed: Migrate (Newznab) nzb.su to nzb.life
Co-authored-by: Stevie<stevie.robinson@gmail.com>
This commit is contained in:
parent
516b09ca91
commit
1318ff0cb4
2 changed files with 104 additions and 0 deletions
|
|
@ -0,0 +1,88 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using Newtonsoft.Json.Linq;
|
||||
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 nzb_su_url_to_nzb_lifeFixture : MigrationTest<nzb_su_url_to_nzb_life>
|
||||
{
|
||||
[TestCase("Newznab", "https://api.nzb.su")]
|
||||
[TestCase("Newznab", "http://api.nzb.su")]
|
||||
public void should_replace_old_url(string impl, string baseUrl)
|
||||
{
|
||||
var db = WithMigrationTestDb(c =>
|
||||
{
|
||||
c.Insert.IntoTable("Indexers").Row(new
|
||||
{
|
||||
Name = "Nzb.su",
|
||||
Implementation = impl,
|
||||
Settings = new NewznabSettings044
|
||||
{
|
||||
BaseUrl = baseUrl,
|
||||
ApiPath = "/api"
|
||||
}.ToJson(),
|
||||
ConfigContract = impl + "Settings",
|
||||
EnableInteractiveSearch = false
|
||||
});
|
||||
});
|
||||
|
||||
var items = db.Query<IndexerDefinition044>("SELECT * FROM \"Indexers\"");
|
||||
|
||||
items.Should().HaveCount(1);
|
||||
items.First().Settings.ToObject<NewznabSettings044>().BaseUrl.Should().Be(baseUrl.Replace("su", "life"));
|
||||
}
|
||||
|
||||
[TestCase("Newznab", "https://api.indexer.com")]
|
||||
public void should_not_replace_different_url(string impl, string baseUrl)
|
||||
{
|
||||
var db = WithMigrationTestDb(c =>
|
||||
{
|
||||
c.Insert.IntoTable("Indexers").Row(new
|
||||
{
|
||||
Name = "Indexer.com",
|
||||
Implementation = impl,
|
||||
Settings = new NewznabSettings044
|
||||
{
|
||||
BaseUrl = baseUrl,
|
||||
ApiPath = "/api"
|
||||
}.ToJson(),
|
||||
ConfigContract = impl + "Settings",
|
||||
EnableInteractiveSearch = false
|
||||
});
|
||||
});
|
||||
|
||||
var items = db.Query<IndexerDefinition044>("SELECT * FROM \"Indexers\"");
|
||||
|
||||
items.Should().HaveCount(1);
|
||||
items.First().Settings.ToObject<NewznabSettings044>().BaseUrl.Should().Be(baseUrl);
|
||||
}
|
||||
}
|
||||
|
||||
internal class IndexerDefinition044
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public JObject Settings { get; set; }
|
||||
public int Priority { get; set; }
|
||||
public string Implementation { get; set; }
|
||||
public string ConfigContract { get; set; }
|
||||
public bool EnableRss { get; set; }
|
||||
public bool EnableAutomaticSearch { get; set; }
|
||||
public bool EnableInteractiveSearch { get; set; }
|
||||
public HashSet<int> Tags { get; set; }
|
||||
public int DownloadClientId { get; set; }
|
||||
public int SeasonSearchMaximumSingleEpisodeAge { get; set; }
|
||||
}
|
||||
|
||||
internal class NewznabSettings044
|
||||
{
|
||||
public string BaseUrl { get; set; }
|
||||
public string ApiPath { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
using FluentMigrator;
|
||||
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migration
|
||||
{
|
||||
[Migration(044)]
|
||||
public class nzb_su_url_to_nzb_life : NzbDroneMigrationBase
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Execute.Sql("UPDATE \"Indexers\" SET \"Settings\" = replace(\"Settings\", '//api.nzb.su', '//api.nzb.life')" +
|
||||
"WHERE \"Implementation\" = 'Newznab'" +
|
||||
"AND \"Settings\" LIKE '%//api.nzb.su%'");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue