2020-02-09 02:35:16 +00:00
|
|
|
|
using System;
|
2015-07-26 03:48:18 +00:00
|
|
|
|
using System.Collections.Generic;
|
2017-10-29 06:21:18 +00:00
|
|
|
|
using System.Collections.Specialized;
|
|
|
|
|
using System.Globalization;
|
2015-07-26 03:48:18 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
2017-10-29 06:21:18 +00:00
|
|
|
|
using System.Text.RegularExpressions;
|
2015-07-26 03:48:18 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2017-10-29 06:21:18 +00:00
|
|
|
|
using CsQuery;
|
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:21:18 +00:00
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using NLog;
|
2017-04-15 08:45:10 +00:00
|
|
|
|
|
2018-03-10 08:05:56 +00:00
|
|
|
|
namespace Jackett.Common.Indexers
|
2015-07-26 03:48:18 +00:00
|
|
|
|
{
|
2017-07-10 20:58:44 +00:00
|
|
|
|
public class HDSpace : BaseWebIndexer
|
2015-07-26 03:48:18 +00:00
|
|
|
|
{
|
2015-07-27 00:03:51 +00:00
|
|
|
|
private string LoginUrl { get { return SiteLink + "index.php?page=login"; } }
|
2016-10-27 16:50:58 +00:00
|
|
|
|
private string SearchUrl { get { return SiteLink + "index.php?page=torrents&"; } }
|
2015-07-26 03:48:18 +00:00
|
|
|
|
|
2017-10-29 06:21:18 +00:00
|
|
|
|
private new ConfigurationDataBasicLogin configData
|
2015-08-03 21:38:45 +00:00
|
|
|
|
{
|
|
|
|
|
get { return (ConfigurationDataBasicLogin)base.configData; }
|
|
|
|
|
set { base.configData = value; }
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-05 09:42:03 +00:00
|
|
|
|
public HDSpace(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
|
2015-07-26 03:48:18 +00:00
|
|
|
|
: base(name: "HD-Space",
|
|
|
|
|
description: "Sharing The Universe",
|
2015-07-27 00:03:51 +00:00
|
|
|
|
link: "https://hd-space.org/",
|
2015-08-11 18:48:25 +00:00
|
|
|
|
caps: TorznabUtil.CreateDefaultTorznabTVCaps(),
|
2017-07-10 20:58:44 +00:00
|
|
|
|
configService: configService,
|
2015-07-27 00:03:51 +00:00
|
|
|
|
client: wc,
|
2015-08-03 21:38:45 +00:00
|
|
|
|
logger: l,
|
2015-08-07 19:09:13 +00:00
|
|
|
|
p: ps,
|
2015-08-03 21:38:45 +00:00
|
|
|
|
configData: new ConfigurationDataBasicLogin())
|
2015-07-26 03:48:18 +00:00
|
|
|
|
{
|
2017-11-05 09:42:03 +00:00
|
|
|
|
Encoding = Encoding.UTF8;
|
2016-12-09 17:20:58 +00:00
|
|
|
|
Language = "en-us";
|
2017-01-27 15:57:32 +00:00
|
|
|
|
Type = "private";
|
2016-12-06 13:56:47 +00:00
|
|
|
|
|
2016-08-26 08:22:02 +00:00
|
|
|
|
AddCategoryMapping(15, TorznabCatType.MoviesBluRay); // Movie / Blu-ray
|
|
|
|
|
AddMultiCategoryMapping(TorznabCatType.MoviesHD,
|
|
|
|
|
19, // Movie / 1080p
|
|
|
|
|
41, // Movie / 4K UHD
|
|
|
|
|
18, // Movie / 720p
|
|
|
|
|
40, // Movie / Remux
|
|
|
|
|
16 // Movie / HD-DVD
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
AddMultiCategoryMapping(TorznabCatType.TVHD,
|
|
|
|
|
21, // TV Show / 720p HDTV
|
|
|
|
|
22 // TV Show / 1080p HDTV
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
AddCategoryMapping(30, TorznabCatType.AudioLossless); // Music / Lossless
|
|
|
|
|
AddCategoryMapping(31, TorznabCatType.AudioVideo); // Music / Videos
|
2017-10-29 06:21:18 +00:00
|
|
|
|
|
2016-08-26 08:22:02 +00:00
|
|
|
|
AddMultiCategoryMapping(TorznabCatType.TVDocumentary,
|
|
|
|
|
24, // TV Show / Documentary / 720p
|
|
|
|
|
25 // TV Show / Documentary / 1080p
|
|
|
|
|
);
|
2017-10-29 06:21:18 +00:00
|
|
|
|
|
2016-08-26 08:22:02 +00:00
|
|
|
|
AddMultiCategoryMapping(TorznabCatType.XXX,
|
|
|
|
|
33, // XXX / 720p
|
|
|
|
|
34 // XXX / 1080p
|
|
|
|
|
);
|
2017-10-29 06:21:18 +00:00
|
|
|
|
|
2016-08-26 08:22:02 +00:00
|
|
|
|
AddCategoryMapping("37", TorznabCatType.PC);
|
|
|
|
|
AddCategoryMapping("38", TorznabCatType.Other);
|
2017-10-29 06:21:18 +00:00
|
|
|
|
}
|
2015-07-26 03:48:18 +00:00
|
|
|
|
|
2017-06-28 05:31:38 +00:00
|
|
|
|
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
2015-07-26 03:48:18 +00:00
|
|
|
|
{
|
2017-01-02 20:39:28 +00:00
|
|
|
|
LoadValuesFromJson(configJson);
|
2015-07-26 03:48:18 +00:00
|
|
|
|
|
2015-07-28 19:22:23 +00:00
|
|
|
|
var loginPage = await RequestStringWithCookies(LoginUrl, string.Empty);
|
2015-07-26 03:48:18 +00:00
|
|
|
|
|
|
|
|
|
var pairs = new Dictionary<string, string> {
|
2015-08-03 21:38:45 +00:00
|
|
|
|
{ "uid", configData.Username.Value },
|
|
|
|
|
{ "pwd", configData.Password.Value }
|
2015-07-26 03:48:18 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Send Post
|
2015-07-28 19:22:23 +00:00
|
|
|
|
var response = await RequestLoginAndFollowRedirect(LoginUrl, pairs, loginPage.Cookies, true, null, LoginUrl);
|
2015-07-26 03:48:18 +00:00
|
|
|
|
|
2015-08-02 17:28:59 +00:00
|
|
|
|
await ConfigureIfOK(response.Cookies, response.Content != null && response.Content.Contains("logout.php"), () =>
|
2015-07-26 03:48:18 +00:00
|
|
|
|
{
|
|
|
|
|
var errorStr = "You have {0} remaining login attempts";
|
|
|
|
|
var remainingAttemptSpan = new Regex(string.Format(errorStr, "(.*?)")).Match(loginPage.Content).Groups[1].ToString();
|
|
|
|
|
var attempts = Regex.Replace(remainingAttemptSpan, "<.*?>", String.Empty);
|
|
|
|
|
var errorMessage = string.Format(errorStr, attempts);
|
2015-08-03 21:38:45 +00:00
|
|
|
|
throw new ExceptionWithConfigData(errorMessage, configData);
|
2015-07-26 03:48:18 +00:00
|
|
|
|
});
|
2015-08-22 20:57:13 +00:00
|
|
|
|
return IndexerConfigurationStatus.RequiresTesting;
|
2015-07-26 03:48:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-03 05:15:47 +00:00
|
|
|
|
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
2015-07-26 03:48:18 +00:00
|
|
|
|
{
|
2015-07-28 23:10:04 +00:00
|
|
|
|
var releases = new List<ReleaseInfo>();
|
2016-10-27 16:50:58 +00:00
|
|
|
|
|
|
|
|
|
var searchString = query.GetQueryString();
|
|
|
|
|
var searchUrl = SearchUrl;
|
2017-04-15 08:45:10 +00:00
|
|
|
|
var queryCollection = new NameValueCollection();
|
|
|
|
|
queryCollection.Add("active", "0");
|
|
|
|
|
queryCollection.Add("options", "0");
|
|
|
|
|
queryCollection.Add("category", string.Join(";", MapTorznabCapsToTrackers(query)));
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchString))
|
|
|
|
|
{
|
|
|
|
|
queryCollection.Add("search", searchString);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
searchUrl += queryCollection.GetQueryString();
|
|
|
|
|
|
2016-10-27 16:50:58 +00:00
|
|
|
|
var response = await RequestStringWithCookiesAndRetry(searchUrl);
|
2015-07-26 03:48:18 +00:00
|
|
|
|
var results = response.Content;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
CQ dom = results;
|
|
|
|
|
var rows = dom["table.lista > tbody > tr"];
|
|
|
|
|
foreach (var row in rows)
|
|
|
|
|
{
|
|
|
|
|
// this tracker has horrible markup, find the result rows by looking for the style tag before each one
|
|
|
|
|
var prev = row.PreviousElementSibling;
|
2020-02-09 02:35:16 +00:00
|
|
|
|
if (prev == null || prev.NodeName.ToLowerInvariant() != "style")
|
|
|
|
|
continue;
|
2015-07-26 03:48:18 +00:00
|
|
|
|
|
|
|
|
|
CQ qRow = row.Cq();
|
|
|
|
|
var release = new ReleaseInfo();
|
|
|
|
|
|
|
|
|
|
release.MinimumRatio = 1;
|
2020-01-11 18:07:19 +00:00
|
|
|
|
release.MinimumSeedTime = 172800; // 48 hours
|
2015-07-26 03:48:18 +00:00
|
|
|
|
|
|
|
|
|
var qLink = row.ChildElements.ElementAt(1).FirstElementChild.Cq();
|
|
|
|
|
release.Title = qLink.Text().Trim();
|
|
|
|
|
release.Comments = new Uri(SiteLink + qLink.Attr("href"));
|
|
|
|
|
release.Guid = release.Comments;
|
|
|
|
|
|
|
|
|
|
var qDownload = row.ChildElements.ElementAt(3).FirstElementChild.Cq();
|
|
|
|
|
release.Link = new Uri(SiteLink + qDownload.Attr("href"));
|
|
|
|
|
|
|
|
|
|
//"July 11, 2015, 13:34:09", "Today at 20:04:23"
|
|
|
|
|
var dateStr = row.ChildElements.ElementAt(4).Cq().Text().Trim();
|
|
|
|
|
if (dateStr.StartsWith("Today"))
|
|
|
|
|
release.PublishDate = DateTime.Today + TimeSpan.ParseExact(dateStr.Replace("Today at ", ""), "hh\\:mm\\:ss", CultureInfo.InvariantCulture);
|
|
|
|
|
else if (dateStr.StartsWith("Yesterday"))
|
|
|
|
|
release.PublishDate = DateTime.Today - TimeSpan.FromDays(1) + TimeSpan.ParseExact(dateStr.Replace("Yesterday at ", ""), "hh\\:mm\\:ss", CultureInfo.InvariantCulture);
|
|
|
|
|
else
|
|
|
|
|
release.PublishDate = DateTime.SpecifyKind(DateTime.ParseExact(dateStr, "MMMM dd, yyyy, HH:mm:ss", CultureInfo.InvariantCulture), DateTimeKind.Local);
|
|
|
|
|
|
|
|
|
|
var sizeStr = row.ChildElements.ElementAt(5).Cq().Text();
|
|
|
|
|
release.Size = ReleaseInfo.GetBytes(sizeStr);
|
|
|
|
|
|
|
|
|
|
release.Seeders = ParseUtil.CoerceInt(row.ChildElements.ElementAt(7).Cq().Text());
|
|
|
|
|
release.Peers = ParseUtil.CoerceInt(row.ChildElements.ElementAt(8).Cq().Text()) + release.Seeders;
|
|
|
|
|
|
2016-10-27 07:35:31 +00:00
|
|
|
|
var grabs = qRow.Find("td:nth-child(10)").Text();
|
|
|
|
|
grabs = grabs.Replace("---", "0");
|
|
|
|
|
release.Grabs = ParseUtil.CoerceInt(grabs);
|
|
|
|
|
|
2017-04-15 08:45:10 +00:00
|
|
|
|
if (qRow.Find("img[title=\"FreeLeech\"]").Length >= 1)
|
|
|
|
|
release.DownloadVolumeFactor = 0;
|
|
|
|
|
else if (qRow.Find("img[src=\"images/sf.png\"]").Length >= 1) // side freeleech
|
|
|
|
|
release.DownloadVolumeFactor = 0;
|
|
|
|
|
else if (qRow.Find("img[title=\"Half FreeLeech\"]").Length >= 1)
|
|
|
|
|
release.DownloadVolumeFactor = 0.5;
|
2016-10-27 07:35:31 +00:00
|
|
|
|
else
|
|
|
|
|
release.DownloadVolumeFactor = 1;
|
|
|
|
|
|
|
|
|
|
release.UploadVolumeFactor = 1;
|
|
|
|
|
|
2016-10-27 16:50:58 +00:00
|
|
|
|
var qCat = qRow.Find("a[href^=\"index.php?page=torrents&category=\"]");
|
|
|
|
|
var cat = qCat.Attr("href").Split('=')[2];
|
|
|
|
|
release.Category = MapTrackerCatToNewznab(cat);
|
|
|
|
|
|
2015-07-26 03:48:18 +00:00
|
|
|
|
releases.Add(release);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
OnParseError(results, ex);
|
|
|
|
|
}
|
2015-07-28 23:10:04 +00:00
|
|
|
|
return releases;
|
2015-07-26 03:48:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|