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;
|
2020-05-03 23:35:52 +00:00
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2020-03-15 21:38:54 +00:00
|
|
|
|
using System.Linq;
|
2015-07-26 03:48:18 +00:00
|
|
|
|
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;
|
2020-02-28 22:32:02 +00:00
|
|
|
|
using AngleSharp.Html.Parser;
|
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
|
|
|
|
{
|
2020-05-03 23:35:52 +00:00
|
|
|
|
[ExcludeFromCodeCoverage]
|
2017-07-10 20:58:44 +00:00
|
|
|
|
public class HDSpace : BaseWebIndexer
|
2015-07-26 03:48:18 +00:00
|
|
|
|
{
|
2020-02-25 16:08:03 +00:00
|
|
|
|
private string LoginUrl => SiteLink + "index.php?page=login";
|
|
|
|
|
private string SearchUrl => SiteLink + "index.php?page=torrents&";
|
2015-07-26 03:48:18 +00:00
|
|
|
|
|
2020-05-03 23:00:04 +00:00
|
|
|
|
private new ConfigurationDataBasicLogin configData => (ConfigurationDataBasicLogin)base.configData;
|
2015-08-03 21:38:45 +00:00
|
|
|
|
|
2017-11-05 09:42:03 +00:00
|
|
|
|
public HDSpace(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
|
2020-05-11 19:59:28 +00:00
|
|
|
|
: base(id: "hdspace",
|
|
|
|
|
name: "HD-Space",
|
2020-02-28 22:32:02 +00:00
|
|
|
|
description: "Sharing The Universe",
|
|
|
|
|
link: "https://hd-space.org/",
|
|
|
|
|
caps: TorznabUtil.CreateDefaultTorznabTVCaps(),
|
|
|
|
|
configService: configService,
|
|
|
|
|
client: wc,
|
|
|
|
|
logger: l,
|
|
|
|
|
p: ps,
|
2020-05-03 23:00:04 +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";
|
2020-03-15 21:38:54 +00:00
|
|
|
|
TorznabCaps.SupportsImdbMovieSearch = true;
|
2020-04-09 19:48:59 +00:00
|
|
|
|
// TorznabCaps.SupportsImdbTVSearch = true; (supported by the site but disabled due to #8107)
|
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,
|
2020-02-28 22:32:02 +00:00
|
|
|
|
19, // Movie / 1080p
|
|
|
|
|
18, // Movie / 720p
|
|
|
|
|
40, // Movie / Remux
|
|
|
|
|
16 // Movie / HD-DVD
|
|
|
|
|
);
|
2016-08-26 08:22:02 +00:00
|
|
|
|
AddMultiCategoryMapping(TorznabCatType.TVHD,
|
2020-02-28 22:32:02 +00:00
|
|
|
|
21, // TV Show / 720p HDTV
|
|
|
|
|
22 // TV Show / 1080p HDTV
|
|
|
|
|
);
|
2016-08-26 08:22:02 +00:00
|
|
|
|
AddMultiCategoryMapping(TorznabCatType.TVDocumentary,
|
2020-05-03 23:00:04 +00:00
|
|
|
|
24, // Documentary / 720p
|
|
|
|
|
25 // Documentary / 1080p
|
2020-02-28 22:32:02 +00:00
|
|
|
|
);
|
2020-05-03 23:00:04 +00:00
|
|
|
|
AddMultiCategoryMapping(TorznabCatType.TVAnime,
|
|
|
|
|
27, // Animation / 720p
|
|
|
|
|
28 // Animation / 1080p
|
|
|
|
|
);
|
|
|
|
|
AddCategoryMapping(30, TorznabCatType.AudioLossless); // Music / HQ Audio
|
|
|
|
|
AddCategoryMapping(31, TorznabCatType.AudioVideo); // Music / Videos
|
2016-08-26 08:22:02 +00:00
|
|
|
|
AddMultiCategoryMapping(TorznabCatType.XXX,
|
2020-02-28 22:32:02 +00:00
|
|
|
|
33, // XXX / 720p
|
|
|
|
|
34 // XXX / 1080p
|
|
|
|
|
);
|
2020-05-03 23:00:04 +00:00
|
|
|
|
AddCategoryMapping(36, TorznabCatType.MoviesOther); // Trailers
|
|
|
|
|
AddCategoryMapping(37, TorznabCatType.PC); // Software
|
|
|
|
|
AddCategoryMapping(38, TorznabCatType.Other); // Others
|
|
|
|
|
AddCategoryMapping(41, TorznabCatType.MoviesUHD); // Movie / 4K UHD
|
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);
|
2020-09-21 06:02:53 +00:00
|
|
|
|
var loginPage = await RequestStringWithCookies(LoginUrl, string.Empty);
|
2020-02-28 22:32:02 +00:00
|
|
|
|
var pairs = new Dictionary<string, string>
|
|
|
|
|
{
|
|
|
|
|
{"uid", configData.Username.Value},
|
|
|
|
|
{"pwd", configData.Password.Value}
|
2015-07-26 03:48:18 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Send Post
|
2020-03-15 21:38:54 +00:00
|
|
|
|
var response = await RequestLoginAndFollowRedirect(LoginUrl, pairs, loginPage.Cookies, true, referer: LoginUrl);
|
2015-07-26 03:48:18 +00:00
|
|
|
|
|
2020-09-21 06:04:26 +00:00
|
|
|
|
await ConfigureIfOK(response.Cookies, response.Content?.Contains("logout.php") == true, () =>
|
2015-07-26 03:48:18 +00:00
|
|
|
|
{
|
|
|
|
|
var errorStr = "You have {0} remaining login attempts";
|
2020-02-28 22:32:02 +00:00
|
|
|
|
var remainingAttemptSpan = new Regex(string.Format(errorStr, "(.*?)"))
|
2020-09-21 06:04:26 +00:00
|
|
|
|
.Match(loginPage.Content).Groups[1].ToString();
|
2020-02-10 22:16:19 +00:00
|
|
|
|
var attempts = Regex.Replace(remainingAttemptSpan, "<.*?>", string.Empty);
|
2015-07-26 03:48:18 +00:00
|
|
|
|
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>();
|
2020-02-28 22:32:02 +00:00
|
|
|
|
var queryCollection = new NameValueCollection
|
|
|
|
|
{
|
|
|
|
|
{"active", "0"},
|
|
|
|
|
{"category", string.Join(";", MapTorznabCapsToTrackers(query))}
|
|
|
|
|
};
|
2016-10-27 16:50:58 +00:00
|
|
|
|
|
2020-03-15 21:38:54 +00:00
|
|
|
|
if (query.IsImdbQuery)
|
|
|
|
|
{
|
|
|
|
|
queryCollection.Add("options", "2");
|
|
|
|
|
queryCollection.Add("search", query.ImdbIDShort);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
queryCollection.Add("options", "0");
|
|
|
|
|
queryCollection.Add("search", query.GetQueryString());
|
|
|
|
|
}
|
2017-04-15 08:45:10 +00:00
|
|
|
|
|
2020-09-21 06:02:53 +00:00
|
|
|
|
var response = await RequestStringWithCookiesAndRetry(SearchUrl + queryCollection.GetQueryString());
|
2015-07-26 03:48:18 +00:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2020-02-28 22:32:02 +00:00
|
|
|
|
var resultParser = new HtmlParser();
|
2020-09-21 06:04:26 +00:00
|
|
|
|
var searchResultDocument = resultParser.ParseDocument(response.Content);
|
2020-02-28 22:32:02 +00:00
|
|
|
|
var rows = searchResultDocument.QuerySelectorAll("table.lista > tbody > tr");
|
|
|
|
|
|
2015-07-26 03:48:18 +00:00
|
|
|
|
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-03-15 21:38:54 +00:00
|
|
|
|
if (prev == null || !string.Equals(prev.NodeName, "style", StringComparison.OrdinalIgnoreCase))
|
2020-02-09 02:35:16 +00:00
|
|
|
|
continue;
|
2015-07-26 03:48:18 +00:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2020-02-28 22:32:02 +00:00
|
|
|
|
var qLink = row.Children[1].FirstElementChild;
|
|
|
|
|
release.Title = qLink.TextContent.Trim();
|
|
|
|
|
release.Comments = new Uri(SiteLink + qLink.GetAttribute("href"));
|
2015-07-26 03:48:18 +00:00
|
|
|
|
release.Guid = release.Comments;
|
|
|
|
|
|
2020-03-15 21:38:54 +00:00
|
|
|
|
var imdbLink = row.Children[1].QuerySelector("a[href*=imdb]");
|
2020-04-07 16:17:17 +00:00
|
|
|
|
if (imdbLink != null)
|
2020-03-15 21:38:54 +00:00
|
|
|
|
release.Imdb = ParseUtil.GetImdbID(imdbLink.GetAttribute("href").Split('/').Last());
|
2020-04-07 16:17:17 +00:00
|
|
|
|
|
2020-02-28 22:32:02 +00:00
|
|
|
|
var qDownload = row.Children[3].FirstElementChild;
|
|
|
|
|
release.Link = new Uri(SiteLink + qDownload.GetAttribute("href"));
|
2015-07-26 03:48:18 +00:00
|
|
|
|
|
2020-02-28 22:32:02 +00:00
|
|
|
|
var dateStr = row.Children[4].TextContent.Trim();
|
|
|
|
|
//"July 11, 2015, 13:34:09", "Today|Yesterday at 20:04:23"
|
2020-03-15 21:38:54 +00:00
|
|
|
|
release.PublishDate = DateTimeUtil.FromUnknown(dateStr);
|
2020-02-28 22:32:02 +00:00
|
|
|
|
var sizeStr = row.Children[5].TextContent;
|
2015-07-26 03:48:18 +00:00
|
|
|
|
release.Size = ReleaseInfo.GetBytes(sizeStr);
|
2020-02-28 22:32:02 +00:00
|
|
|
|
release.Seeders = ParseUtil.CoerceInt(row.Children[7].TextContent);
|
|
|
|
|
release.Peers = ParseUtil.CoerceInt(row.Children[8].TextContent) + release.Seeders;
|
|
|
|
|
var grabs = row.QuerySelector("td:nth-child(10)").TextContent;
|
2016-10-27 07:35:31 +00:00
|
|
|
|
grabs = grabs.Replace("---", "0");
|
|
|
|
|
release.Grabs = ParseUtil.CoerceInt(grabs);
|
2020-02-28 22:32:02 +00:00
|
|
|
|
if (row.QuerySelector("img[title=\"FreeLeech\"]") != null)
|
2017-04-15 08:45:10 +00:00
|
|
|
|
release.DownloadVolumeFactor = 0;
|
2020-02-28 22:32:02 +00:00
|
|
|
|
else if (row.QuerySelector("img[src=\"images/sf.png\"]") != null) // side freeleech
|
2017-04-15 08:45:10 +00:00
|
|
|
|
release.DownloadVolumeFactor = 0;
|
2020-02-28 22:32:02 +00:00
|
|
|
|
else if (row.QuerySelector("img[title=\"Half FreeLeech\"]") != null)
|
2017-04-15 08:45:10 +00:00
|
|
|
|
release.DownloadVolumeFactor = 0.5;
|
2016-10-27 07:35:31 +00:00
|
|
|
|
else
|
|
|
|
|
release.DownloadVolumeFactor = 1;
|
|
|
|
|
release.UploadVolumeFactor = 1;
|
2020-02-28 22:32:02 +00:00
|
|
|
|
var qCat = row.QuerySelector("a[href^=\"index.php?page=torrents&category=\"]");
|
|
|
|
|
var cat = qCat.GetAttribute("href").Split('=')[2];
|
2016-10-27 16:50:58 +00:00
|
|
|
|
release.Category = MapTrackerCatToNewznab(cat);
|
2015-07-26 03:48:18 +00:00
|
|
|
|
releases.Add(release);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2020-09-21 06:04:26 +00:00
|
|
|
|
OnParseError(response.Content, ex);
|
2015-07-26 03:48:18 +00:00
|
|
|
|
}
|
2020-02-28 22:32:02 +00:00
|
|
|
|
|
2015-07-28 23:10:04 +00:00
|
|
|
|
return releases;
|
2015-07-26 03:48:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|