From 9b712769b5c391d53c72b83048aeed3d340cfa41 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 10 Aug 2015 19:15:15 -0600 Subject: [PATCH] Added additional torznab categories, implemented AlphaRatio categories --- src/Jackett/Indexers/AlphaRatio.cs | 40 ++++++++- src/Jackett/Indexers/IPTorrents.cs | 1 - src/Jackett/Models/TorznabCatType.cs | 125 +++++++++++++++++++++++---- 3 files changed, 146 insertions(+), 20 deletions(-) diff --git a/src/Jackett/Indexers/AlphaRatio.cs b/src/Jackett/Indexers/AlphaRatio.cs index 19e5f5065..48c78b675 100644 --- a/src/Jackett/Indexers/AlphaRatio.cs +++ b/src/Jackett/Indexers/AlphaRatio.cs @@ -15,13 +15,14 @@ using NLog; using Jackett.Services; using Jackett.Utils.Clients; using Jackett.Models.IndexerConfig; +using System.Collections.Specialized; namespace Jackett.Indexers { public class AlphaRatio : BaseIndexer, IIndexer { private string LoginUrl { get { return SiteLink + "login.php"; } } - private string SearchUrl { get { return SiteLink + "ajax.php?action=browse&searchstr="; } } + private string SearchUrl { get { return SiteLink + "ajax.php?action=browse&"; } } private string DownloadUrl { get { return SiteLink + "torrents.php?action=download&id="; } } private string GuidUrl { get { return SiteLink + "torrents.php?torrentid="; } } @@ -36,7 +37,22 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataBasicLogin()) { - webclient = w; + AddCategoryMapping(1, TorznabCatType.TVSD); + AddCategoryMapping(2, TorznabCatType.TVHD); + AddCategoryMapping(6, TorznabCatType.MoviesSD); + AddCategoryMapping(7, TorznabCatType.MoviesHD); + AddCategoryMapping(10, TorznabCatType.XXX); + AddCategoryMapping(20, TorznabCatType.XXX); + AddCategoryMapping(12, TorznabCatType.PCGames); + AddCategoryMapping(13, TorznabCatType.GameXbox); + AddCategoryMapping(14, TorznabCatType.GamePS3); + AddCategoryMapping(15, TorznabCatType.GameWii); + AddCategoryMapping(16, TorznabCatType.PC); + AddCategoryMapping(17, TorznabCatType.PCMac); + AddCategoryMapping(19, TorznabCatType.PCMobileOther); + AddCategoryMapping(21, TorznabCatType.EBook); + AddCategoryMapping(22, TorznabCatType.AudioBooks); + AddCategoryMapping(23, TorznabCatType.Audio); } public async Task ApplyConfiguration(JToken configJson) @@ -76,8 +92,24 @@ namespace Jackett.Indexers { var releases = new List(); var searchString = query.SanitizedSearchTerm + " " + query.GetEpisodeSearchString(); - var episodeSearchUrl = SearchUrl + HttpUtility.UrlEncode(searchString); - var response = await RequestStringWithCookiesAndRetry(episodeSearchUrl); + + var searchUrl = SearchUrl; + var queryCollection = new NameValueCollection(); + queryCollection.Add("order_by", "time"); + queryCollection.Add("order_way", "desc"); + + if (!string.IsNullOrWhiteSpace(searchString)) + { + queryCollection.Add("searchstr", searchString); + } + + foreach (var cat in MapTorznabCapsToTrackers(query)) + { + queryCollection.Add("filter_cat[" + cat + "]", "1"); + } + + searchUrl += queryCollection.GetQueryString(); + var response = await RequestStringWithCookiesAndRetry(searchUrl); try { diff --git a/src/Jackett/Indexers/IPTorrents.cs b/src/Jackett/Indexers/IPTorrents.cs index ed844114f..249902e61 100644 --- a/src/Jackett/Indexers/IPTorrents.cs +++ b/src/Jackett/Indexers/IPTorrents.cs @@ -116,7 +116,6 @@ namespace Jackett.Indexers var releases = new List(); var searchString = query.SanitizedSearchTerm + " " + query.GetEpisodeSearchString(); var searchUrl = BrowseUrl; - var trackerCats = MapTorznabCapsToTrackers(query); var queryCollection = new NameValueCollection(); if (!string.IsNullOrWhiteSpace(searchString)) diff --git a/src/Jackett/Models/TorznabCatType.cs b/src/Jackett/Models/TorznabCatType.cs index 16faba13f..66949a3ad 100644 --- a/src/Jackett/Models/TorznabCatType.cs +++ b/src/Jackett/Models/TorznabCatType.cs @@ -37,13 +37,13 @@ namespace Jackett.Models public static bool QueryContainsParentCategory(int[] queryCats, int releaseCat) { - if (cats.ContainsKey(releaseCat) && queryCats!=null) + if (cats.ContainsKey(releaseCat) && queryCats != null) { var ncab = cats[releaseCat]; var split = ncab.IndexOf("/"); if (split > -1) { - string parentCatName = ncab.Substring(0,split); + string parentCatName = ncab.Substring(0, split); if (cats.ContainsValue(parentCatName)) { var parentCat = cats.Where(c => c.Value == parentCatName).First().Key; @@ -70,7 +70,7 @@ namespace Jackett.Models return new TorznabCategory() { ID = id, - Name = cats[id] + Name = cats.ContainsKey(id) ? cats[id] : string.Empty }; } @@ -99,11 +99,26 @@ namespace Jackett.Models get { return GetCat(5040); } } + public static TorznabCategory TVSport + { + get { return GetCat(5060); } + } + + public static TorznabCategory TVForeign + { + get { return GetCat(5020); } + } + public static TorznabCategory Books { get { return GetCat(8000); } } + public static TorznabCategory EBook + { + get { return GetCat(7020); } + } + public static TorznabCategory Comic { get { return GetCat(8020); } @@ -114,21 +129,21 @@ namespace Jackett.Models get { return GetCat(4000); } } - public static TorznabCategory PCGames - { - get { return GetCat(4050); } - } - - public static TorznabCategory AudioBooks - { - get { return GetCat(3030); } - } - public static TorznabCategory Movies { get { return GetCat(2000); } } + public static TorznabCategory MoviesForeign + { + get { return GetCat(2010); } + } + + public static TorznabCategory MoviesOther + { + get { return GetCat(2020); } + } + public static TorznabCategory MoviesHD { get { return GetCat(2040); } @@ -139,9 +154,14 @@ namespace Jackett.Models get { return GetCat(2030); } } - public static TorznabCategory MoviesForeign + public static TorznabCategory MoviesBlueRay { - get { return GetCat(2040); } + get { return GetCat(2050); } + } + + public static TorznabCategory Movies3D + { + get { return GetCat(2060); } } public static TorznabCategory Audio @@ -149,6 +169,11 @@ namespace Jackett.Models get { return GetCat(3000); } } + public static TorznabCategory AudioBooks + { + get { return GetCat(3030); } + } + public static TorznabCategory AudioLossless { get { return GetCat(3040); } @@ -178,5 +203,75 @@ namespace Jackett.Models { get { return GetCat(6060); } } + + public static TorznabCategory PC + { + get { return GetCat(4000); } + } + + public static TorznabCategory PC0Day + { + get { return GetCat(4010); } + } + + public static TorznabCategory PCIso + { + get { return GetCat(4020); } + } + + public static TorznabCategory PCMac + { + get { return GetCat(4030); } + } + + public static TorznabCategory PCGames + { + get { return GetCat(4050); } + } + + public static TorznabCategory PCMobileOther + { + get { return GetCat(4040); } + } + + public static TorznabCategory PCMobileIos + { + get { return GetCat(4060); } + } + + public static TorznabCategory PCMobileAndroid + { + get { return GetCat(4070); } + } + + public static TorznabCategory GameDNS + { + get { return GetCat(1010); } + } + + public static TorznabCategory GamePSP + { + get { return GetCat(1020); } + } + + public static TorznabCategory GameXbox + { + get { return GetCat(1040); } + } + + public static TorznabCategory GameXbox360 + { + get { return GetCat(1050); } + } + + public static TorznabCategory GameWii + { + get { return GetCat(1030); } + } + + public static TorznabCategory GamePS3 + { + get { return GetCat(1080); } + } } }