From e1c29b7723ec113590e55aafd618ecc176a2c357 Mon Sep 17 00:00:00 2001 From: flightlevel Date: Wed, 9 Dec 2015 19:45:44 +1100 Subject: [PATCH] Speed.Cd: Add categories Speed.Cd: Add categories --- src/Jackett/Indexers/SpeedCD.cs | 75 ++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 24 deletions(-) diff --git a/src/Jackett/Indexers/SpeedCD.cs b/src/Jackett/Indexers/SpeedCD.cs index 8bfbd5592..7f683c319 100644 --- a/src/Jackett/Indexers/SpeedCD.cs +++ b/src/Jackett/Indexers/SpeedCD.cs @@ -8,13 +8,8 @@ using NLog; using System; using System.Collections.Generic; using System.Globalization; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; -using System.Web; using Jackett.Models.IndexerConfig; namespace Jackett.Indexers @@ -23,7 +18,6 @@ namespace Jackett.Indexers { private string LoginUrl { get { return SiteLink + "take.login.php"; } } private string SearchUrl { get { return SiteLink + "V3/API/API.php"; } } - private string SearchFormData { get { return "c53=1&c49=1&c2=1&c52=1&c41=1&c50=1&c30=1&c1=1&c42=1&c32=1&c43=1&c47=1&c28=1&c48=1&c40=1&jxt=4&jxw=b"; } } private string CommentsUrl { get { return SiteLink + "t/{0}"; } } private string DownloadUrl { get { return SiteLink + "download.php?torrent={0}"; } } @@ -37,24 +31,41 @@ namespace Jackett.Indexers : base(name: "Speed.cd", description: "Your home now!", link: "http://speed.cd/", - caps: new TorznabCapabilities(TorznabCatType.Movies, - TorznabCatType.TV, - TorznabCatType.TVSD, - TorznabCatType.TVHD, - TorznabCatType.Movies, - TorznabCatType.MoviesOther, - TorznabCatType.MoviesHD, - TorznabCatType.Movies3D, - TorznabCatType.MoviesBluRay, - TorznabCatType.MoviesDVD - ), + caps: new TorznabCapabilities(), manager: i, client: wc, logger: l, p: ps, configData: new ConfigurationDataBasicLogin()) { - + AddCategoryMapping("1", TorznabCatType.MoviesOther); + AddCategoryMapping("42", TorznabCatType.Movies); + AddCategoryMapping("32", TorznabCatType.Movies); + AddCategoryMapping("43", TorznabCatType.MoviesHD); + AddCategoryMapping("47", TorznabCatType.Movies); + AddCategoryMapping("28", TorznabCatType.MoviesBluRay); + AddCategoryMapping("48", TorznabCatType.Movies3D); + AddCategoryMapping("40", TorznabCatType.MoviesDVD); + AddCategoryMapping("49", TorznabCatType.TVHD); + AddCategoryMapping("50", TorznabCatType.TVSport); + AddCategoryMapping("52", TorznabCatType.TVHD); + AddCategoryMapping("53", TorznabCatType.TVSD); + AddCategoryMapping("41", TorznabCatType.TV); + AddCategoryMapping("55", TorznabCatType.TV); + AddCategoryMapping("2", TorznabCatType.TV); + AddCategoryMapping("30", TorznabCatType.TVAnime); + AddCategoryMapping("25", TorznabCatType.PCISO); + AddCategoryMapping("39", TorznabCatType.ConsoleWii); + AddCategoryMapping("45", TorznabCatType.ConsolePS3); + AddCategoryMapping("35", TorznabCatType.Console); + AddCategoryMapping("33", TorznabCatType.ConsoleXbox360); + AddCategoryMapping("46", TorznabCatType.PCPhoneOther); + AddCategoryMapping("24", TorznabCatType.PC0day); + AddCategoryMapping("51", TorznabCatType.PCMac); + AddCategoryMapping("27", TorznabCatType.Books); + AddCategoryMapping("26", TorznabCatType.Audio); + AddCategoryMapping("44", TorznabCatType.Audio); + AddCategoryMapping("29", TorznabCatType.AudioVideo); } public async Task ApplyConfiguration(JToken configJson) @@ -79,10 +90,23 @@ namespace Jackett.Indexers public async Task> PerformQuery(TorznabQuery query) { var releases = new List(); - var formData = HttpUtility.ParseQueryString(SearchFormData); - var formDict = formData.AllKeys.ToDictionary(t => t, t => formData[t]); - formDict.Add("search", query.SanitizedSearchTerm); - var response = await PostDataWithCookiesAndRetry(SearchUrl, formDict); + + Dictionary qParams = new Dictionary(); + qParams.Add("jxt", "4"); + qParams.Add("jxw", "b"); + + if (!string.IsNullOrEmpty(query.SanitizedSearchTerm)) + { + qParams.Add("search", query.SanitizedSearchTerm); + } + + List catList = MapTorznabCapsToTrackers(query); + foreach (string cat in catList) + { + qParams.Add("c" + cat, "1"); + } + + var response = await PostDataWithCookiesAndRetry(SearchUrl, qParams); try { var jsonResult = JObject.Parse(response.Content); @@ -101,14 +125,17 @@ namespace Jackett.Indexers var SizeStr = ((string)jobj["size"]); release.Size = ReleaseInfo.GetBytes(SizeStr); + var cat = (int)jobj["cat"]; + release.Category = MapTrackerCatToNewznab(cat.ToString()); + release.Seeders = ParseUtil.CoerceInt((string)jobj["seed"]); release.Peers = ParseUtil.CoerceInt((string)jobj["leech"]) + release.Seeders; // ex: Tuesday, May 26, 2015 at 6:00pm var dateStr = new Regex("title=\"(.*?)\"").Match((string)jobj["added"]).Groups[1].ToString(); dateStr = dateStr.Replace(" at", ""); - var dateTime = DateTime.ParseExact(dateStr, "dddd, MMMM d, yyyy h:mmtt", CultureInfo.InvariantCulture); - release.PublishDate = dateTime; + var dateTime = DateTime.ParseExact(dateStr, "dddd, MMMM d, yyyy h:mmtt", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal); + release.PublishDate = dateTime.ToLocalTime(); releases.Add(release); }