2020-02-09 02:35:16 +00:00
|
|
|
using System;
|
2015-07-19 02:19:09 +00:00
|
|
|
using System.Collections.Generic;
|
2020-05-03 23:35:52 +00:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2015-07-19 02:19:09 +00:00
|
|
|
using System.Globalization;
|
2020-04-26 18:09:11 +00:00
|
|
|
using System.Linq;
|
2016-12-09 17:20:58 +00:00
|
|
|
using System.Text;
|
2020-04-30 11:10:03 +00:00
|
|
|
using System.Text.RegularExpressions;
|
2015-07-19 02:19:09 +00:00
|
|
|
using System.Threading.Tasks;
|
2020-02-29 20:29:51 +00:00
|
|
|
using AngleSharp.Html.Parser;
|
2020-04-28 20:36:42 +00:00
|
|
|
using Jackett.Common.Helpers;
|
2018-03-10 08:05:56 +00:00
|
|
|
using Jackett.Common.Models;
|
|
|
|
using Jackett.Common.Models.IndexerConfig;
|
|
|
|
using Jackett.Common.Services.Interfaces;
|
|
|
|
using Jackett.Common.Utils;
|
|
|
|
using Jackett.Common.Utils.Clients;
|
2017-10-29 06:50:47 +00:00
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
using NLog;
|
2015-07-19 02:19:09 +00:00
|
|
|
|
2018-03-10 08:05:56 +00:00
|
|
|
namespace Jackett.Common.Indexers
|
2015-07-19 02:19:09 +00:00
|
|
|
{
|
2020-05-03 23:35:52 +00:00
|
|
|
[ExcludeFromCodeCoverage]
|
2017-07-10 20:58:44 +00:00
|
|
|
public class SpeedCD : BaseWebIndexer
|
2015-07-19 02:19:09 +00:00
|
|
|
{
|
2020-04-30 11:10:03 +00:00
|
|
|
private string LoginUrl1 => SiteLink + "checkpoint/API";
|
|
|
|
private string LoginUrl2 => SiteLink + "checkpoint/";
|
2020-04-28 20:36:42 +00:00
|
|
|
private string SearchUrl => SiteLink + "browse/";
|
2015-08-03 21:38:45 +00:00
|
|
|
|
2020-03-31 20:26:07 +00:00
|
|
|
public override string[] AlternativeSiteLinks { get; protected set; } = {
|
|
|
|
"https://speed.cd/",
|
2021-01-18 15:22:03 +00:00
|
|
|
"https://speed.click/",
|
|
|
|
"https://speeders.me/"
|
2020-03-31 20:26:07 +00:00
|
|
|
};
|
|
|
|
|
2020-04-30 11:10:03 +00:00
|
|
|
private new ConfigurationDataBasicLogin configData => (ConfigurationDataBasicLogin)base.configData;
|
2015-08-03 21:38:45 +00:00
|
|
|
|
2020-12-11 22:14:21 +00:00
|
|
|
public SpeedCD(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps,
|
|
|
|
ICacheService cs)
|
2020-05-11 19:59:28 +00:00
|
|
|
: base(id: "speedcd",
|
|
|
|
name: "Speed.cd",
|
2020-04-26 18:09:11 +00:00
|
|
|
description: "Your home now!",
|
|
|
|
link: "https://speed.cd/",
|
|
|
|
caps: new TorznabCapabilities
|
|
|
|
{
|
2020-10-18 20:47:36 +00:00
|
|
|
TvSearchParams = new List<TvSearchParam>
|
|
|
|
{
|
|
|
|
TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep, TvSearchParam.ImdbId
|
|
|
|
},
|
|
|
|
MovieSearchParams = new List<MovieSearchParam>
|
|
|
|
{
|
|
|
|
MovieSearchParam.Q, MovieSearchParam.ImdbId
|
2020-10-20 00:38:27 +00:00
|
|
|
},
|
|
|
|
MusicSearchParams = new List<MusicSearchParam>
|
|
|
|
{
|
|
|
|
MusicSearchParam.Q
|
|
|
|
},
|
|
|
|
BookSearchParams = new List<BookSearchParam>
|
|
|
|
{
|
|
|
|
BookSearchParam.Q
|
2020-10-18 20:47:36 +00:00
|
|
|
}
|
2020-04-26 18:09:11 +00:00
|
|
|
},
|
|
|
|
configService: configService,
|
|
|
|
client: wc,
|
|
|
|
logger: l,
|
|
|
|
p: ps,
|
2020-12-11 22:14:21 +00:00
|
|
|
cacheService: cs,
|
2020-04-30 11:10:03 +00:00
|
|
|
configData: new ConfigurationDataBasicLogin(
|
2020-04-26 18:09:11 +00:00
|
|
|
@"Speed.Cd have increased their security. If you are having problems please check the security tab
|
2020-03-31 20:26:07 +00:00
|
|
|
in your Speed.Cd profile. Eg. Geo Locking, your seedbox may be in a different country to the one where you login via your
|
|
|
|
web browser.<br><br>For best results, change the 'Torrents per page' setting to 100 in 'Profile Settings > Torrents'."))
|
2015-07-19 02:19:09 +00:00
|
|
|
{
|
2016-12-09 17:20:58 +00:00
|
|
|
Encoding = Encoding.UTF8;
|
|
|
|
Language = "en-us";
|
2017-01-27 15:57:32 +00:00
|
|
|
Type = "private";
|
2016-12-09 17:20:58 +00:00
|
|
|
|
2019-02-11 23:58:20 +00:00
|
|
|
AddCategoryMapping(1, TorznabCatType.MoviesOther, "Movies/XviD");
|
|
|
|
AddCategoryMapping(42, TorznabCatType.Movies, "Movies/Packs");
|
|
|
|
AddCategoryMapping(32, TorznabCatType.Movies, "Movies/Kids");
|
|
|
|
AddCategoryMapping(43, TorznabCatType.MoviesHD, "Movies/HD");
|
|
|
|
AddCategoryMapping(47, TorznabCatType.Movies, "Movies/DiVERSiTY");
|
|
|
|
AddCategoryMapping(28, TorznabCatType.MoviesBluRay, "Movies/B-Ray");
|
|
|
|
AddCategoryMapping(48, TorznabCatType.Movies3D, "Movies/3D");
|
|
|
|
AddCategoryMapping(40, TorznabCatType.MoviesDVD, "Movies/DVD-R");
|
|
|
|
AddCategoryMapping(56, TorznabCatType.Movies, "Movies/Anime");
|
|
|
|
AddCategoryMapping(50, TorznabCatType.TVSport, "TV/Sports");
|
|
|
|
AddCategoryMapping(52, TorznabCatType.TVHD, "TV/B-Ray");
|
|
|
|
AddCategoryMapping(53, TorznabCatType.TVSD, "TV/DVD-R");
|
|
|
|
AddCategoryMapping(41, TorznabCatType.TV, "TV/Packs");
|
|
|
|
AddCategoryMapping(55, TorznabCatType.TV, "TV/Kids");
|
|
|
|
AddCategoryMapping(57, TorznabCatType.TV, "TV/DiVERSiTY");
|
|
|
|
AddCategoryMapping(49, TorznabCatType.TVHD, "TV/HD");
|
|
|
|
AddCategoryMapping(2, TorznabCatType.TVSD, "TV/Episodes");
|
|
|
|
AddCategoryMapping(30, TorznabCatType.TVAnime, "TV/Anime");
|
|
|
|
AddCategoryMapping(25, TorznabCatType.PCISO, "Games/PC ISO");
|
|
|
|
AddCategoryMapping(39, TorznabCatType.ConsoleWii, "Games/Wii");
|
|
|
|
AddCategoryMapping(45, TorznabCatType.ConsolePS3, "Games/PS3");
|
|
|
|
AddCategoryMapping(35, TorznabCatType.Console, "Games/Nintendo");
|
2020-10-28 19:00:48 +00:00
|
|
|
AddCategoryMapping(33, TorznabCatType.ConsoleXBox360, "Games/XboX360");
|
|
|
|
AddCategoryMapping(46, TorznabCatType.PCMobileOther, "Mobile");
|
2019-02-11 23:58:20 +00:00
|
|
|
AddCategoryMapping(24, TorznabCatType.PC0day, "Apps/0DAY");
|
|
|
|
AddCategoryMapping(51, TorznabCatType.PCMac, "Mac");
|
|
|
|
AddCategoryMapping(54, TorznabCatType.Books, "Educational");
|
|
|
|
AddCategoryMapping(27, TorznabCatType.Books, "Books-Mags");
|
|
|
|
AddCategoryMapping(26, TorznabCatType.Audio, "Music/Audio");
|
2020-08-17 18:11:55 +00:00
|
|
|
AddCategoryMapping(3, TorznabCatType.Audio, "Music/Flac");
|
2019-02-11 23:58:20 +00:00
|
|
|
AddCategoryMapping(44, TorznabCatType.Audio, "Music/Pack");
|
|
|
|
AddCategoryMapping(29, TorznabCatType.AudioVideo, "Music/Video");
|
2015-07-19 02:19:09 +00:00
|
|
|
}
|
|
|
|
|
2017-06-28 05:31:38 +00:00
|
|
|
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
2015-07-19 02:19:09 +00:00
|
|
|
{
|
2017-01-02 20:39:28 +00:00
|
|
|
LoadValuesFromJson(configJson);
|
2020-04-30 11:10:03 +00:00
|
|
|
await DoLogin();
|
|
|
|
return IndexerConfigurationStatus.RequiresTesting;
|
|
|
|
}
|
|
|
|
|
|
|
|
private async Task DoLogin()
|
|
|
|
{
|
|
|
|
// first request with username
|
|
|
|
var pairs = new Dictionary<string, string> {
|
|
|
|
{ "username", configData.Username.Value }
|
|
|
|
};
|
|
|
|
var result = await RequestLoginAndFollowRedirect(LoginUrl1, pairs, null, true, null, SiteLink);
|
|
|
|
var tokenRegex = new Regex(@"name=\\""a\\"" value=\\""([^""]+)\\""");
|
2020-06-09 17:36:57 +00:00
|
|
|
var matches = tokenRegex.Match(result.ContentString);
|
2020-04-30 11:10:03 +00:00
|
|
|
if (!matches.Success)
|
|
|
|
throw new Exception("Error parsing the login form");
|
|
|
|
var token = matches.Groups[1].Value;
|
|
|
|
|
|
|
|
// second request with token and password
|
|
|
|
pairs = new Dictionary<string, string> {
|
|
|
|
{ "pwd", configData.Password.Value },
|
|
|
|
{ "a", token }
|
|
|
|
};
|
|
|
|
result = await RequestLoginAndFollowRedirect(LoginUrl2, pairs, result.Cookies, true, null, SiteLink);
|
|
|
|
|
2020-06-09 17:36:57 +00:00
|
|
|
await ConfigureIfOK(result.Cookies, result.ContentString?.Contains("/browse.php") == true, () =>
|
2020-04-26 18:09:11 +00:00
|
|
|
{
|
2020-04-30 11:10:03 +00:00
|
|
|
var parser = new HtmlParser();
|
2020-06-09 17:36:57 +00:00
|
|
|
var dom = parser.ParseDocument(result.ContentString);
|
2020-04-30 11:10:03 +00:00
|
|
|
var errorMessage = dom.QuerySelector("h5")?.TextContent;
|
2020-06-09 17:36:57 +00:00
|
|
|
if (result.ContentString.Contains("Wrong Captcha!"))
|
2020-04-30 11:10:03 +00:00
|
|
|
errorMessage = "Captcha required due to a failed login attempt. Login via a browser to whitelist your IP and then reconfigure Jackett.";
|
|
|
|
throw new Exception(errorMessage);
|
|
|
|
});
|
2015-07-19 02:19:09 +00:00
|
|
|
}
|
|
|
|
|
2017-07-03 05:15:47 +00:00
|
|
|
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
2015-07-19 02:19:09 +00:00
|
|
|
{
|
2015-07-27 00:03:51 +00:00
|
|
|
var releases = new List<ReleaseInfo>();
|
2015-12-09 08:45:44 +00:00
|
|
|
|
2020-04-28 20:36:42 +00:00
|
|
|
// the order of the params is important!
|
|
|
|
var qc = new List<string>();
|
|
|
|
|
|
|
|
var catList = MapTorznabCapsToTrackers(query);
|
|
|
|
foreach (var cat in catList)
|
|
|
|
qc.Add(cat);
|
|
|
|
|
2020-03-31 20:26:07 +00:00
|
|
|
if (query.IsImdbQuery)
|
2015-12-09 08:45:44 +00:00
|
|
|
{
|
2020-04-28 20:36:42 +00:00
|
|
|
qc.Add("deep");
|
|
|
|
qc.Add("q");
|
|
|
|
qc.Add(query.ImdbID);
|
2015-12-09 08:45:44 +00:00
|
|
|
}
|
2020-03-31 20:26:07 +00:00
|
|
|
else
|
2020-04-28 20:36:42 +00:00
|
|
|
{
|
|
|
|
qc.Add("q");
|
|
|
|
qc.Add(WebUtilityHelpers.UrlEncode(query.GetQueryString(), Encoding));
|
|
|
|
}
|
2016-01-19 13:08:00 +00:00
|
|
|
|
2020-04-28 20:36:42 +00:00
|
|
|
var searchUrl = SearchUrl + string.Join("/", qc);
|
2020-06-11 15:09:27 +00:00
|
|
|
var response = await RequestWithCookiesAndRetryAsync(searchUrl);
|
2020-06-09 17:36:57 +00:00
|
|
|
if (!response.ContentString.Contains("/logout.php")) // re-login
|
2020-04-30 11:10:03 +00:00
|
|
|
{
|
|
|
|
await DoLogin();
|
2020-06-11 15:09:27 +00:00
|
|
|
response = await RequestWithCookiesAndRetryAsync(searchUrl);
|
2020-04-30 11:10:03 +00:00
|
|
|
}
|
2015-07-19 02:19:09 +00:00
|
|
|
|
2016-01-19 13:08:00 +00:00
|
|
|
try
|
|
|
|
{
|
2020-02-29 20:29:51 +00:00
|
|
|
var parser = new HtmlParser();
|
2020-06-09 17:36:57 +00:00
|
|
|
var dom = parser.ParseDocument(response.ContentString);
|
2020-03-31 20:26:07 +00:00
|
|
|
var rows = dom.QuerySelectorAll("div.boxContent > table > tbody > tr");
|
2015-07-19 02:19:09 +00:00
|
|
|
|
2020-02-10 22:16:19 +00:00
|
|
|
foreach (var row in rows)
|
2016-01-19 13:08:00 +00:00
|
|
|
{
|
2020-02-29 20:29:51 +00:00
|
|
|
var cells = row.QuerySelectorAll("td");
|
2020-02-10 22:16:19 +00:00
|
|
|
|
2020-02-29 20:29:51 +00:00
|
|
|
var title = row.QuerySelector("td[class='lft'] > div > a").TextContent.Trim();
|
2020-03-31 20:26:07 +00:00
|
|
|
var link = new Uri(SiteLink + row.QuerySelector("img[title='Download']").ParentElement.GetAttribute("href").TrimStart('/'));
|
2020-11-08 02:11:27 +00:00
|
|
|
var details = new Uri(SiteLink + row.QuerySelector("td[class='lft'] > div > a").GetAttribute("href").TrimStart('/'));
|
2020-04-28 20:36:42 +00:00
|
|
|
var size = ReleaseInfo.GetBytes(cells[5].TextContent);
|
|
|
|
var grabs = ParseUtil.CoerceInt(cells[6].TextContent);
|
|
|
|
var seeders = ParseUtil.CoerceInt(cells[7].TextContent);
|
|
|
|
var leechers = ParseUtil.CoerceInt(cells[8].TextContent);
|
2020-02-10 22:16:19 +00:00
|
|
|
|
2020-03-31 20:26:07 +00:00
|
|
|
var pubDateStr = row.QuerySelector("span[class^='elapsedDate']").GetAttribute("title").Replace(" at", "");
|
|
|
|
var publishDate = DateTime.ParseExact(pubDateStr, "dddd, MMMM d, yyyy h:mmtt", CultureInfo.InvariantCulture);
|
2020-02-10 22:16:19 +00:00
|
|
|
|
2020-04-28 20:36:42 +00:00
|
|
|
var cat = row.QuerySelector("a").GetAttribute("href").Split('/').Last();
|
2020-03-26 22:15:28 +00:00
|
|
|
var downloadVolumeFactor = row.QuerySelector("span:contains(\"[Freeleech]\")") != null ? 0 : 1;
|
2020-03-31 20:26:07 +00:00
|
|
|
|
2020-03-26 22:15:28 +00:00
|
|
|
var release = new ReleaseInfo
|
|
|
|
{
|
|
|
|
Title = title,
|
|
|
|
Link = link,
|
2020-03-31 20:26:07 +00:00
|
|
|
Guid = link,
|
2020-11-08 02:11:27 +00:00
|
|
|
Details = details,
|
2020-03-26 22:15:28 +00:00
|
|
|
PublishDate = publishDate,
|
2020-03-31 20:26:07 +00:00
|
|
|
Category = MapTrackerCatToNewznab(cat),
|
2020-03-26 22:15:28 +00:00
|
|
|
Size = size,
|
|
|
|
Grabs = grabs,
|
|
|
|
Seeders = seeders,
|
|
|
|
Peers = seeders + leechers,
|
|
|
|
MinimumRatio = 1,
|
2021-01-25 22:25:00 +00:00
|
|
|
MinimumSeedTime = 259200, // 72 hours
|
2020-03-26 22:15:28 +00:00
|
|
|
DownloadVolumeFactor = downloadVolumeFactor,
|
|
|
|
UploadVolumeFactor = 1
|
|
|
|
};
|
2020-03-31 20:26:07 +00:00
|
|
|
|
2015-07-19 02:19:09 +00:00
|
|
|
releases.Add(release);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
2020-06-09 17:36:57 +00:00
|
|
|
OnParseError(response.ContentString, ex);
|
2015-07-19 02:19:09 +00:00
|
|
|
}
|
2015-07-28 23:10:04 +00:00
|
|
|
return releases;
|
2015-07-19 02:19:09 +00:00
|
|
|
}
|
|
|
|
}
|
2016-01-20 08:45:39 +00:00
|
|
|
}
|