diff --git a/src/Jackett.Common/Indexers/BaseIndexer.cs b/src/Jackett.Common/Indexers/BaseIndexer.cs index c268ebc92..90030372c 100644 --- a/src/Jackett.Common/Indexers/BaseIndexer.cs +++ b/src/Jackett.Common/Indexers/BaseIndexer.cs @@ -359,15 +359,12 @@ namespace Jackett.Common.Indexers { protected BaseWebIndexer(string link, string id, string name, string description, IIndexerConfigurationService configService, WebClient client, Logger logger, - ConfigurationData configData, IProtectionService p, TorznabCapabilities caps = null, + ConfigurationData configData, IProtectionService p, TorznabCapabilities caps, string downloadBase = null) : base(link, id, name, description, configService, logger, configData, p) { webclient = client; downloadUrlBase = downloadBase; - - if (caps == null) - caps = TorznabUtil.CreateDefaultTorznabTVCaps(); TorznabCaps = caps; } diff --git a/src/Jackett.Common/Indexers/BitCityReloaded.cs b/src/Jackett.Common/Indexers/BitCityReloaded.cs index 8f456320b..145fa0712 100644 --- a/src/Jackett.Common/Indexers/BitCityReloaded.cs +++ b/src/Jackett.Common/Indexers/BitCityReloaded.cs @@ -35,7 +35,7 @@ namespace Jackett.Common.Indexers name: "Bit-City Reloaded", description: "A German general tracker.", link: "https://bc-reloaded.net/", - caps: TorznabUtil.CreateDefaultTorznabTVCaps(), + caps: new TorznabCapabilities(), configService: configService, client: wc, logger: l, diff --git a/src/Jackett.Common/Indexers/DarmoweTorrenty.cs b/src/Jackett.Common/Indexers/DarmoweTorrenty.cs index 3d93fe24b..4151e7217 100644 --- a/src/Jackett.Common/Indexers/DarmoweTorrenty.cs +++ b/src/Jackett.Common/Indexers/DarmoweTorrenty.cs @@ -35,8 +35,22 @@ namespace Jackett.Common.Indexers set => base.configData = value; } - private void MapCategories() + public DarmoweTorenty(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) + : base(id: "darmowetorenty", + name: "Darmowe torenty", + description: "Darmowe torenty is a POLISH Semi-Private Torrent Tracker for MOVIES / TV / GENERAL", + link: "https://darmowe-torenty.pl/", + caps: new TorznabCapabilities(), + configService: configService, + client: wc, + logger: l, + p: ps, + configData: new ConfigurationDataBasicLoginWithRSSAndDisplay()) { + Encoding = Encoding.GetEncoding("iso-8859-2"); + Language = "pl-pl"; + Type = "semi-private"; + AddCategoryMapping(14, TorznabCatType.Movies, "Filmy"); AddCategoryMapping(27, TorznabCatType.MoviesDVD, "Filmy DVD-R"); AddCategoryMapping(28, TorznabCatType.MoviesSD, "Filmy VCD/SVCD"); @@ -92,24 +106,6 @@ namespace Jackett.Common.Indexers AddCategoryMapping(76, TorznabCatType.Other, "Archiwum"); } - public DarmoweTorenty(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) - : base(id: "darmowetorenty", - name: "Darmowe torenty", - description: "Darmowe torenty is a POLISH Semi-Private Torrent Tracker for MOVIES / TV / GENERAL", - link: "https://darmowe-torenty.pl/", - caps: TorznabUtil.CreateDefaultTorznabTVCaps(), - configService: configService, - client: wc, - logger: l, - p: ps, - configData: new ConfigurationDataBasicLoginWithRSSAndDisplay()) - { - Encoding = Encoding.GetEncoding("iso-8859-2"); - Language = "pl-pl"; - Type = "semi-private"; - MapCategories(); - } - public override async Task ApplyConfiguration(JToken configJson) { LoadValuesFromJson(configJson); diff --git a/src/Jackett.Common/Indexers/Feeds/AnimeTosho.cs b/src/Jackett.Common/Indexers/Feeds/AnimeTosho.cs index 78cb33592..2337738ed 100644 --- a/src/Jackett.Common/Indexers/Feeds/AnimeTosho.cs +++ b/src/Jackett.Common/Indexers/Feeds/AnimeTosho.cs @@ -21,26 +21,18 @@ namespace Jackett.Common.Indexers.Feeds name: "Anime Tosho", description: "AnimeTosho (AT) is an automated service that provides torrent files, magnet links and DDL for all anime releases", link: "https://animetosho.org/", + caps: new TorznabCapabilities(), configService: configService, client: client, logger: logger, p: ps, configData: new ConfigurationData()) { - // TODO - // this might be downloaded and refreshed instead of hard-coding it - TorznabCaps = new TorznabCapabilities(new TorznabCategory(5070, "Anime")) - { - SearchAvailable = true, - TVSearchAvailable = false, - MovieSearchAvailable = false, - SupportsImdbMovieSearch = false, - SupportsTVRageSearch = false - }; - Encoding = Encoding.UTF8; Language = "en-en"; Type = "public"; + + AddCategoryMapping(1, TorznabCatType.TVAnime); } protected override async Task> PerformQuery(TorznabQuery query) diff --git a/src/Jackett.Common/Indexers/HDSpace.cs b/src/Jackett.Common/Indexers/HDSpace.cs index 290baec23..d13555f36 100644 --- a/src/Jackett.Common/Indexers/HDSpace.cs +++ b/src/Jackett.Common/Indexers/HDSpace.cs @@ -30,7 +30,11 @@ namespace Jackett.Common.Indexers name: "HD-Space", description: "Sharing The Universe", link: "https://hd-space.org/", - caps: TorznabUtil.CreateDefaultTorznabTVCaps(), + caps: new TorznabCapabilities + { + SupportsImdbMovieSearch = true + //SupportsImdbTVSearch = true; (supported by the site but disabled due to #8107) + }, configService: configService, client: wc, logger: l, @@ -40,8 +44,6 @@ namespace Jackett.Common.Indexers Encoding = Encoding.UTF8; Language = "en-us"; Type = "private"; - TorznabCaps.SupportsImdbMovieSearch = true; - // TorznabCaps.SupportsImdbTVSearch = true; (supported by the site but disabled due to #8107) AddCategoryMapping(15, TorznabCatType.MoviesBluRay); // Movie / Blu-ray AddMultiCategoryMapping(TorznabCatType.MoviesHD, diff --git a/src/Jackett.Common/Indexers/Hebits.cs b/src/Jackett.Common/Indexers/Hebits.cs index 248688a71..a500a07d7 100644 --- a/src/Jackett.Common/Indexers/Hebits.cs +++ b/src/Jackett.Common/Indexers/Hebits.cs @@ -34,7 +34,7 @@ namespace Jackett.Common.Indexers name: "Hebits", description: "The Israeli Tracker", link: "https://hebits.net/", - caps: TorznabUtil.CreateDefaultTorznabTVCaps(), + caps: new TorznabCapabilities(), configService: configService, client: wc, logger: l, @@ -45,6 +45,7 @@ namespace Jackett.Common.Indexers Encoding = Encoding.GetEncoding("windows-1255"); Language = "he-il"; Type = "private"; + AddCategoryMapping(21, TorznabCatType.PCGames, "משחקים - PC (PC Games)"); AddCategoryMapping(33, TorznabCatType.Console, "משחקים - קונסולות (Console Games)"); AddCategoryMapping(19, TorznabCatType.MoviesSD, "סרטי SD (Movies SD)"); diff --git a/src/Jackett.Common/Indexers/ImmortalSeed.cs b/src/Jackett.Common/Indexers/ImmortalSeed.cs index c81f41083..09a532b2c 100644 --- a/src/Jackett.Common/Indexers/ImmortalSeed.cs +++ b/src/Jackett.Common/Indexers/ImmortalSeed.cs @@ -39,7 +39,7 @@ namespace Jackett.Common.Indexers name: "ImmortalSeed", description: "ImmortalSeed (iS) is a Private Torrent Tracker for MOVIES / TV / GENERAL", link: "https://immortalseed.me/", - caps: TorznabUtil.CreateDefaultTorznabTVCaps(), + caps: new TorznabCapabilities(), configService: configService, client: wc, logger: l, diff --git a/src/Jackett.Common/Indexers/LostFilm.cs b/src/Jackett.Common/Indexers/LostFilm.cs index d3ac7bf0d..43fc491c1 100644 --- a/src/Jackett.Common/Indexers/LostFilm.cs +++ b/src/Jackett.Common/Indexers/LostFilm.cs @@ -98,7 +98,7 @@ namespace Jackett.Common.Indexers name: "LostFilm.tv", description: "Unique portal about foreign series", link: "https://www.lostfilm.run/", - caps: TorznabUtil.CreateDefaultTorznabTVCaps(), + caps: new TorznabCapabilities(), configService: configService, client: wc, logger: l, @@ -108,6 +108,8 @@ namespace Jackett.Common.Indexers Encoding = Encoding.UTF8; Language = "ru-ru"; Type = "semi-private"; + + AddCategoryMapping(1, TorznabCatType.Movies); } public override async Task GetConfigurationForSetup() diff --git a/src/Jackett.Common/Indexers/Meta/BaseMetaIndexer.cs b/src/Jackett.Common/Indexers/Meta/BaseMetaIndexer.cs index 4eea54332..30261a449 100644 --- a/src/Jackett.Common/Indexers/Meta/BaseMetaIndexer.cs +++ b/src/Jackett.Common/Indexers/Meta/BaseMetaIndexer.cs @@ -23,7 +23,7 @@ namespace Jackett.Common.Indexers.Meta name: name, description: description, link: "http://127.0.0.1/", - caps: null, + caps: new TorznabCapabilities(), configService: configService, client: client, logger: logger, diff --git a/src/Jackett.Common/Indexers/MyAmity.cs b/src/Jackett.Common/Indexers/MyAmity.cs index 21f85ce33..cc2ea493c 100644 --- a/src/Jackett.Common/Indexers/MyAmity.cs +++ b/src/Jackett.Common/Indexers/MyAmity.cs @@ -33,7 +33,7 @@ namespace Jackett.Common.Indexers name: "myAmity", description: "A German general tracker.", link: "https://ttv2.myamity.info/", - caps: TorznabUtil.CreateDefaultTorznabTVCaps(), + caps: new TorznabCapabilities(), configService: configService, client: wc, logger: l, diff --git a/src/Jackett.Common/Indexers/Nebulance.cs b/src/Jackett.Common/Indexers/Nebulance.cs index 46b790d91..61ed31e27 100644 --- a/src/Jackett.Common/Indexers/Nebulance.cs +++ b/src/Jackett.Common/Indexers/Nebulance.cs @@ -29,7 +29,7 @@ namespace Jackett.Common.Indexers name: "Nebulance", description: "At Nebulance we will change the way you think about TV", link: "https://nebulance.io/", - caps: TorznabUtil.CreateDefaultTorznabTVCaps(), + caps: new TorznabCapabilities(), configService: configService, client: c, logger: l, @@ -41,6 +41,10 @@ namespace Jackett.Common.Indexers Encoding = Encoding.UTF8; Language = "en-us"; Type = "private"; + + AddCategoryMapping(1, TorznabCatType.TV); + AddCategoryMapping(2, TorznabCatType.TVSD); + AddCategoryMapping(3, TorznabCatType.TVHD); } public override async Task ApplyConfiguration(JToken configJson) diff --git a/src/Jackett.Common/Indexers/NewRealWorld.cs b/src/Jackett.Common/Indexers/NewRealWorld.cs index dc61af9a7..62d8de361 100644 --- a/src/Jackett.Common/Indexers/NewRealWorld.cs +++ b/src/Jackett.Common/Indexers/NewRealWorld.cs @@ -34,7 +34,7 @@ namespace Jackett.Common.Indexers name: "New Real World", description: "A German general tracker.", link: "https://nrw-tracker.eu/", - caps: TorznabUtil.CreateDefaultTorznabTVCaps(), + caps: new TorznabCapabilities(), configService: configService, client: wc, logger: l, diff --git a/src/Jackett.Common/Indexers/Partis.cs b/src/Jackett.Common/Indexers/Partis.cs index a6638c1a7..3f5e3de55 100644 --- a/src/Jackett.Common/Indexers/Partis.cs +++ b/src/Jackett.Common/Indexers/Partis.cs @@ -33,7 +33,7 @@ namespace Jackett.Common.Indexers name: "Partis", description: "Partis is a SLOVENIAN Private Torrent Tracker", link: "https://www.partis.si/", - caps: TorznabUtil.CreateDefaultTorznabTVCaps(), + caps: new TorznabCapabilities(), configService: configService, client: wc, logger: l, diff --git a/src/Jackett.Common/Indexers/PreToMe.cs b/src/Jackett.Common/Indexers/PreToMe.cs index 66be2fcd0..52ee56bc0 100644 --- a/src/Jackett.Common/Indexers/PreToMe.cs +++ b/src/Jackett.Common/Indexers/PreToMe.cs @@ -28,7 +28,11 @@ namespace Jackett.Common.Indexers name: "PreToMe", description: "BitTorrent site for High Quality, High Definition (HD) movies and TV Shows", link: "https://pretome.info/", - caps: TorznabUtil.CreateDefaultTorznabTVCaps(), + caps: new TorznabCapabilities + { + SupportsImdbMovieSearch = true + // SupportsImdbTVSearch = true; (supported by the site but disabled due to #8107) + }, client: wc, configService: configService, logger: l, @@ -39,9 +43,6 @@ namespace Jackett.Common.Indexers Language = "en-us"; Type = "private"; - TorznabCaps.SupportsImdbMovieSearch = true; - // TorznabCaps.SupportsImdbTVSearch = true; (supported by the site but disabled due to #8107) - // Unfortunately most of them are tags not categories and they return the parent category // we have to re-add the tags with the parent category so the results are not removed with the filtering diff --git a/src/Jackett.Common/Indexers/RuTracker.cs b/src/Jackett.Common/Indexers/RuTracker.cs index 9f943ede3..8b834def9 100644 --- a/src/Jackett.Common/Indexers/RuTracker.cs +++ b/src/Jackett.Common/Indexers/RuTracker.cs @@ -39,7 +39,7 @@ namespace Jackett.Common.Indexers name: "RuTracker", description: "RuTracker is a Semi-Private Russian torrent site with a thriving file-sharing community", link: "https://rutracker.org/", - caps: TorznabUtil.CreateDefaultTorznabTVCaps(), + caps: new TorznabCapabilities(), configService: configService, client: wc, logger: l, diff --git a/src/Jackett.Common/Indexers/ShowRSS.cs b/src/Jackett.Common/Indexers/ShowRSS.cs index c3dc5cfa6..7f61dd37c 100644 --- a/src/Jackett.Common/Indexers/ShowRSS.cs +++ b/src/Jackett.Common/Indexers/ShowRSS.cs @@ -32,7 +32,7 @@ namespace Jackett.Common.Indexers name: "ShowRSS", description: "showRSS is a service that allows you to keep track of your favorite TV shows", link: "https://showrss.info/", - caps: TorznabUtil.CreateDefaultTorznabTVCaps(), + caps: new TorznabCapabilities(), configService: configService, client: wc, logger: l, @@ -42,6 +42,10 @@ namespace Jackett.Common.Indexers Encoding = Encoding.UTF8; Language = "en-us"; Type = "public"; + + AddCategoryMapping(1, TorznabCatType.TV); + AddCategoryMapping(2, TorznabCatType.TVSD); + AddCategoryMapping(3, TorznabCatType.TVHD); } public override async Task ApplyConfiguration(JToken configJson) @@ -71,6 +75,7 @@ namespace Jackett.Common.Indexers if (!query.MatchQueryStringAND(title)) continue; + // TODO: use Jackett.Common.Utils.TvCategoryParser.ParseTvShowQuality // guess category from title var category = title.Contains("720p") || title.Contains("1080p") ? TorznabCatType.TVHD.ID : diff --git a/src/Jackett.Common/Indexers/Toloka.cs b/src/Jackett.Common/Indexers/Toloka.cs index a4660568c..ff5fb30ee 100644 --- a/src/Jackett.Common/Indexers/Toloka.cs +++ b/src/Jackett.Common/Indexers/Toloka.cs @@ -36,14 +36,14 @@ namespace Jackett.Common.Indexers name: "Toloka.to", description: "Toloka is a Semi-Private Ukrainian torrent site with a thriving file-sharing community", link: "https://toloka.to/", - caps: TorznabUtil.CreateDefaultTorznabTVCaps(), + caps: new TorznabCapabilities(), configService: configService, client: wc, logger: l, p: ps, configData: new ConfigurationDataToloka()) { - Encoding = Encoding.GetEncoding("utf-8"); + Encoding = Encoding.UTF8; Language = "uk-ua"; Type = "semi-private"; diff --git a/src/Jackett.Common/Indexers/TorrenTech.cs b/src/Jackett.Common/Indexers/TorrenTech.cs index b39bba993..8dc5cf9fb 100644 --- a/src/Jackett.Common/Indexers/TorrenTech.cs +++ b/src/Jackett.Common/Indexers/TorrenTech.cs @@ -36,7 +36,7 @@ namespace Jackett.Common.Indexers name: "Torrentech", description: "Torrentech (TTH) is a Private Torrent Tracker for ELECTRONIC MUSIC", link: "https://www.torrentech.org/", - caps: TorznabUtil.CreateDefaultTorznabTVCaps(), + caps: new TorznabCapabilities(), configService: configService, client: wc, logger: l, diff --git a/src/Jackett.Common/Indexers/TorrentBytes.cs b/src/Jackett.Common/Indexers/TorrentBytes.cs index 97520ef8e..450c7a1fc 100644 --- a/src/Jackett.Common/Indexers/TorrentBytes.cs +++ b/src/Jackett.Common/Indexers/TorrentBytes.cs @@ -29,7 +29,11 @@ namespace Jackett.Common.Indexers name: "TorrentBytes", description: "A decade of TorrentBytes", link: "https://www.torrentbytes.net/", - caps: TorznabUtil.CreateDefaultTorznabTVCaps(), + caps: new TorznabCapabilities + { + SupportsImdbMovieSearch = true + // SupportsImdbTVSearch = true (supported by the site but disabled due to #8107) + }, configService: configService, client: wc, logger: l, @@ -40,9 +44,6 @@ namespace Jackett.Common.Indexers Language = "en-us"; Type = "private"; - TorznabCaps.SupportsImdbMovieSearch = true; - // TorznabCaps.SupportsImdbTVSearch = true; (supported by the site but disabled due to #8107) - AddCategoryMapping(23, TorznabCatType.TVAnime, "Anime"); AddCategoryMapping(52, TorznabCatType.PCMac, "Apple/All"); AddCategoryMapping(22, TorznabCatType.PC, "Apps/misc"); diff --git a/src/Jackett.Common/Indexers/TorrentMafya.cs b/src/Jackett.Common/Indexers/TorrentMafya.cs index 7fb27faba..2e2269cb8 100644 --- a/src/Jackett.Common/Indexers/TorrentMafya.cs +++ b/src/Jackett.Common/Indexers/TorrentMafya.cs @@ -31,21 +31,12 @@ namespace Jackett.Common.Indexers public IEnumerable aaData { get; set; } } - private void MapCategories() - { - AddCategoryMapping("games", TorznabCatType.PCGames,"Oyun"); - AddCategoryMapping("programs", TorznabCatType.PC, "Program"); - AddCategoryMapping("movies", TorznabCatType.Movies, "Film"); - AddCategoryMapping("tv", TorznabCatType.TV, "Dizi"); - AddCategoryMapping("apk", TorznabCatType.PCPhoneAndroid, "APK"); - } - public TorrentMafya(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(id: "torrentmafya", name: "TorrentMafya", description: "TorrentMafya is a Turkish general torrent tracker ", link: "https://www.torrentmafya.org/", - caps: TorznabUtil.CreateDefaultTorznabTVCaps(), + caps: new TorznabCapabilities(), configService: configService, client: wc, logger: l, @@ -55,7 +46,12 @@ namespace Jackett.Common.Indexers Encoding = Encoding.UTF8; Language = "tr-tr"; Type = "public"; - MapCategories(); + + AddCategoryMapping("games", TorznabCatType.PCGames,"Oyun"); + AddCategoryMapping("programs", TorznabCatType.PC, "Program"); + AddCategoryMapping("movies", TorznabCatType.Movies, "Film"); + AddCategoryMapping("tv", TorznabCatType.TV, "Dizi"); + AddCategoryMapping("apk", TorznabCatType.PCPhoneAndroid, "APK"); } private static DateTime ParseReleasePublishDate(string date) diff --git a/src/Jackett.Common/Indexers/TorrentSeeds.cs b/src/Jackett.Common/Indexers/TorrentSeeds.cs index 3521b26e7..05a744acd 100644 --- a/src/Jackett.Common/Indexers/TorrentSeeds.cs +++ b/src/Jackett.Common/Indexers/TorrentSeeds.cs @@ -32,7 +32,7 @@ namespace Jackett.Common.Indexers name: "TorrentSeeds", description: "TorrentSeeds is a Private site for MOVIES / TV / GENERAL", link: "https://torrentseeds.org/", - caps: TorznabUtil.CreateDefaultTorznabTVCaps(), + caps: new TorznabCapabilities(), configService: configService, client: wc, logger: l, @@ -42,6 +42,7 @@ namespace Jackett.Common.Indexers Encoding = Encoding.UTF8; Language = "en-us"; Type = "private"; + AddCategoryMapping(13, TorznabCatType.PC0day, "Apps/0DAY"); AddCategoryMapping(37, TorznabCatType.TVAnime, "Anime/HD"); AddCategoryMapping(9, TorznabCatType.TVAnime, "Anime/SD"); diff --git a/src/Jackett.Common/Utils/TorznabCapsUtil.cs b/src/Jackett.Common/Utils/TorznabCapsUtil.cs deleted file mode 100644 index 60698f0f4..000000000 --- a/src/Jackett.Common/Utils/TorznabCapsUtil.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Text.RegularExpressions; -using Jackett.Common.Models; - -namespace Jackett.Common.Utils -{ - public class TorznabUtil - { - private static readonly Regex reduceSpacesRegex = new Regex("\\s{2,}", RegexOptions.Compiled); - private static readonly Regex findYearRegex = new Regex(@"(?<=\[|\(|\s)(\d{4})(?=\]|\)|\s)", RegexOptions.Compiled); - - public static TorznabCapabilities CreateDefaultTorznabTVCaps() - { - var caps = new TorznabCapabilities(); - caps.Categories.AddRange(new[] { - TorznabCatType.TV, - TorznabCatType.TVSD, - TorznabCatType.TVHD - }); - return caps; - } - - private static int GetYearFromTitle(string title) - { - var match = findYearRegex.Match(title); - if (match.Success) - { - var year = ParseUtil.CoerceInt(match.Value); - if (year > 1850 && year < 2100) - { - return year; - } - } - - return 0; - } - } -} diff --git a/src/Jackett.Test/Torznab/TorznabTests.cs b/src/Jackett.Test/Torznab/TorznabTests.cs index c04a19b67..51fd3bd88 100644 --- a/src/Jackett.Test/Torznab/TorznabTests.cs +++ b/src/Jackett.Test/Torznab/TorznabTests.cs @@ -21,6 +21,7 @@ namespace Jackett.Test.Torznab name: "test_name", description: "test_description", link: "https://test.link/", + caps: new TorznabCapabilities(), client: null, configService: null, logger: null, @@ -36,13 +37,9 @@ namespace Jackett.Test.Torznab [Test] public void TestCSharpTorznabCategories() { - // TODO: remove those defauls and remove the class TorznabUtil // TODO: make sure TVSearchAvailable is false by default - // by default all indexers have 3 categories - Assert.AreEqual(3, TorznabCaps.Categories.Count); - Assert.AreEqual(TorznabCatType.TV.ID, TorznabCaps.Categories[0].ID); - Assert.AreEqual(TorznabCatType.TVSD.ID, TorznabCaps.Categories[1].ID); - Assert.AreEqual(TorznabCatType.TVHD.ID, TorznabCaps.Categories[2].ID); + // by default all indexers have 0 categories + Assert.AreEqual(0, TorznabCaps.Categories.Count); Assert.True(TorznabCaps.SearchAvailable); Assert.True(TorznabCaps.TVSearchAvailable); @@ -59,39 +56,38 @@ namespace Jackett.Test.Torznab // TODO: movies category enables MovieSearchAvailable but other categories like tv or books don't // add "int" category (parent category) AddCategoryMapping(1, TorznabCatType.Movies); - Assert.AreEqual(4, TorznabCaps.Categories.Count); - Assert.AreEqual(2000, TorznabCaps.Categories[3].ID); + Assert.AreEqual(1, TorznabCaps.Categories.Count); + Assert.AreEqual(2000, TorznabCaps.Categories[0].ID); Assert.True(TorznabCaps.MovieSearchAvailable); // add "string" category (child category) AddCategoryMapping("mov_sd", TorznabCatType.MoviesSD); - Assert.AreEqual(5, TorznabCaps.Categories.Count); - Assert.AreEqual(2030, TorznabCaps.Categories[4].ID); + Assert.AreEqual(2, TorznabCaps.Categories.Count); + Assert.AreEqual(2030, TorznabCaps.Categories[1].ID); // add subcategory of books (child category) AddCategoryMapping(33, TorznabCatType.BooksComics); - Assert.AreEqual(6, TorznabCaps.Categories.Count); - Assert.AreEqual(8020, TorznabCaps.Categories[5].ID); + Assert.AreEqual(3, TorznabCaps.Categories.Count); + Assert.AreEqual(8020, TorznabCaps.Categories[2].ID); // add int category with description => custom category. it's converted into 2 different categories AddCategoryMapping(44, TorznabCatType.ConsoleXbox, "Console/Xbox_c"); - Assert.AreEqual(8, TorznabCaps.Categories.Count); - Assert.AreEqual(1040, TorznabCaps.Categories[6].ID); - Assert.AreEqual(100044, TorznabCaps.Categories[7].ID); + Assert.AreEqual(5, TorznabCaps.Categories.Count); + Assert.AreEqual(1040, TorznabCaps.Categories[3].ID); + Assert.AreEqual(100044, TorznabCaps.Categories[4].ID); // TODO: we should add a way to add custom categories for string categories // https://github.com/Sonarr/Sonarr/wiki/Implementing-a-Torznab-indexer#caps-endpoint // add string category with description. it's converted into 1 category AddCategoryMapping("con_wii", TorznabCatType.ConsoleWii, "Console/Wii_c"); - Assert.AreEqual(9, TorznabCaps.Categories.Count); - Assert.AreEqual(1030, TorznabCaps.Categories[8].ID); + Assert.AreEqual(6, TorznabCaps.Categories.Count); + Assert.AreEqual(1030, TorznabCaps.Categories[5].ID); // add another int category with description that maps to ConsoleXbox (there are 2 tracker cats => 1 torznab cat) AddCategoryMapping(45, TorznabCatType.ConsoleXbox, "Console/Xbox_c2"); - Assert.AreEqual(10, TorznabCaps.Categories.Count); - //Assert.AreEqual(1040, TorznabCaps.Categories[9].ID); // it's duplicated - Assert.AreEqual(100045, TorznabCaps.Categories[9].ID); + Assert.AreEqual(7, TorznabCaps.Categories.Count); + Assert.AreEqual(100045, TorznabCaps.Categories[6].ID); // 1040 is duplicated and it is not added // TODO: test AddMultiCategoryMapping // TODO: add duplicates: different trackerCat but same newznabCat @@ -214,39 +210,31 @@ namespace Jackett.Test.Torznab Assert.AreEqual(0, torznabCats.Count); // TODO: move these methods to TorznabCaps or TorznabQuery classess - // TODO: test Cardignann indexer // test Jackett UI categories (internal JSON) var dto = new Jackett.Common.Models.DTO.Indexer(this); var dtoCaps = dto.caps.ToList(); - Assert.AreEqual(10, dtoCaps.Count); + Assert.AreEqual(7, dtoCaps.Count); Assert.AreEqual("100044", dtoCaps[0].ID); Assert.AreEqual("100045", dtoCaps[1].ID); Assert.AreEqual("1030", dtoCaps[2].ID); Assert.AreEqual("1040", dtoCaps[3].ID); Assert.AreEqual("2000", dtoCaps[4].ID); Assert.AreEqual("2030", dtoCaps[5].ID); - Assert.AreEqual("5000", dtoCaps[6].ID); - Assert.AreEqual("5030", dtoCaps[7].ID); - Assert.AreEqual("5040", dtoCaps[8].ID); - Assert.AreEqual("8020", dtoCaps[9].ID); + Assert.AreEqual("8020", dtoCaps[6].ID); // test Torznab caps (XML) => more in Common.Model.TorznabCapabilitiesTests var xDocument = TorznabCaps.GetXDocument(); var xDoumentCategories = xDocument.Root?.Element("categories")?.Elements("category").ToList(); - Assert.AreEqual(10, xDoumentCategories?.Count); + Assert.AreEqual(7, xDoumentCategories?.Count); Assert.AreEqual("100044", xDoumentCategories?[0].Attribute("id")?.Value); Assert.AreEqual("100045", xDoumentCategories?[1].Attribute("id")?.Value); Assert.AreEqual("1030", xDoumentCategories?[2].Attribute("id")?.Value); Assert.AreEqual("1040", xDoumentCategories?[3].Attribute("id")?.Value); Assert.AreEqual("2000", xDoumentCategories?[4].Attribute("id")?.Value); // Movies Assert.AreEqual("2030", xDoumentCategories?[5].Attribute("id")?.Value); - Assert.AreEqual("5000", xDoumentCategories?[6].Attribute("id")?.Value); // TV - Assert.AreEqual("5030", xDoumentCategories?[7].Attribute("id")?.Value); - Assert.AreEqual("5040", xDoumentCategories?[8].Attribute("id")?.Value); - Assert.AreEqual("8020", xDoumentCategories?[9].Attribute("id")?.Value); + Assert.AreEqual("8020", xDoumentCategories?[6].Attribute("id")?.Value); Assert.AreEqual(9, xDoumentCategories?[4]?.Elements("subcat").ToList().Count); // Movies - Assert.AreEqual(9, xDoumentCategories?[6]?.Elements("subcat").ToList().Count); // TV } [Test] @@ -263,7 +251,6 @@ namespace Jackett.Test.Torznab }; var indexer = new CardigannIndexer(null, null, null, null, definition); - // TODO: this is different from C# indexers // by default all indexers have 0 categories Assert.AreEqual(0, indexer.TorznabCaps.Categories.Count);