Speed.Cd: Add categories

Speed.Cd: Add categories
This commit is contained in:
flightlevel 2015-12-09 19:45:44 +11:00
parent 1d5498e93e
commit e1c29b7723
1 changed files with 51 additions and 24 deletions

View File

@ -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<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
@ -79,10 +90,23 @@ namespace Jackett.Indexers
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
var releases = new List<ReleaseInfo>();
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<string, string> qParams = new Dictionary<string, string>();
qParams.Add("jxt", "4");
qParams.Add("jxw", "b");
if (!string.IsNullOrEmpty(query.SanitizedSearchTerm))
{
qParams.Add("search", query.SanitizedSearchTerm);
}
List<string> 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);
}