2015-07-26 03:48:18 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Jackett.Models;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using Jackett.Utils.Clients;
|
|
|
|
|
using Jackett.Services;
|
|
|
|
|
using NLog;
|
|
|
|
|
using Jackett.Utils;
|
|
|
|
|
using CsQuery;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Globalization;
|
2015-08-03 21:38:45 +00:00
|
|
|
|
using Jackett.Models.IndexerConfig;
|
2016-10-27 16:50:58 +00:00
|
|
|
|
using System.Collections.Specialized;
|
|
|
|
|
|
2015-07-26 03:48:18 +00:00
|
|
|
|
namespace Jackett.Indexers
|
|
|
|
|
{
|
|
|
|
|
public class HDSpace : BaseIndexer, IIndexer
|
|
|
|
|
{
|
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
|
|
|
|
|
2015-08-03 21:38:45 +00:00
|
|
|
|
new ConfigurationDataBasicLogin configData
|
|
|
|
|
{
|
|
|
|
|
get { return (ConfigurationDataBasicLogin)base.configData; }
|
|
|
|
|
set { base.configData = value; }
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-07 19:09:13 +00:00
|
|
|
|
public HDSpace(IIndexerManagerService i, IWebClient 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(),
|
2015-07-26 03:48:18 +00:00
|
|
|
|
manager: i,
|
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
|
|
|
|
{
|
2016-12-06 13:56:47 +00:00
|
|
|
|
Encoding = Encoding.GetEncoding("UTF-8");
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
AddMultiCategoryMapping(TorznabCatType.TVDocumentary,
|
|
|
|
|
24, // TV Show / Documentary / 720p
|
|
|
|
|
25 // TV Show / Documentary / 1080p
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
AddMultiCategoryMapping(TorznabCatType.XXX,
|
|
|
|
|
33, // XXX / 720p
|
|
|
|
|
34 // XXX / 1080p
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
AddCategoryMapping("37", TorznabCatType.PC);
|
|
|
|
|
AddCategoryMapping("38", TorznabCatType.Other);
|
|
|
|
|
}
|
2015-07-26 03:48:18 +00:00
|
|
|
|
|
2015-08-22 20:57:13 +00:00
|
|
|
|
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
2015-07-26 03:48:18 +00:00
|
|
|
|
{
|
2015-08-03 21:38:45 +00:00
|
|
|
|
configData.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
|
|
|
|
}
|
|
|
|
|
|
2015-07-28 23:10:04 +00:00
|
|
|
|
public 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;
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
if (prev == null || prev.NodeName.ToLowerInvariant() != "style") continue;
|
|
|
|
|
|
|
|
|
|
CQ qRow = row.Cq();
|
|
|
|
|
var release = new ReleaseInfo();
|
|
|
|
|
|
|
|
|
|
release.MinimumRatio = 1;
|
|
|
|
|
release.MinimumSeedTime = 172800;
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|