2017-10-29 06:21:18 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.Specialized;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
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-04-15 08:45:10 +00:00
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using NLog;
|
|
|
|
|
|
2018-03-10 08:05:56 +00:00
|
|
|
|
namespace Jackett.Common.Indexers
|
2017-04-15 08:45:10 +00:00
|
|
|
|
{
|
2017-07-10 20:58:44 +00:00
|
|
|
|
public class DigitalHive : BaseWebIndexer
|
2017-04-15 08:45:10 +00:00
|
|
|
|
{
|
|
|
|
|
private string SearchUrl { get { return SiteLink + "browse.php"; } }
|
|
|
|
|
private string LoginUrl { get { return SiteLink + "login.php?returnto=%2F"; } }
|
|
|
|
|
private string AjaxLoginUrl { get { return SiteLink + "takelogin.php"; } }
|
|
|
|
|
|
2017-10-29 06:21:18 +00:00
|
|
|
|
private new ConfigurationDataRecaptchaLogin configData
|
2017-04-15 08:45:10 +00:00
|
|
|
|
{
|
|
|
|
|
get { return (ConfigurationDataRecaptchaLogin)base.configData; }
|
|
|
|
|
set { base.configData = value; }
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-05 09:42:03 +00:00
|
|
|
|
public DigitalHive(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps)
|
2017-04-15 08:45:10 +00:00
|
|
|
|
: base(name: "DigitalHive",
|
|
|
|
|
description: "DigitalHive is one of the oldest general trackers",
|
|
|
|
|
link: "https://www.digitalhive.org/",
|
|
|
|
|
caps: new TorznabCapabilities(),
|
2017-07-10 20:58:44 +00:00
|
|
|
|
configService: configService,
|
2017-04-15 08:45:10 +00:00
|
|
|
|
client: w,
|
|
|
|
|
logger: l,
|
|
|
|
|
p: ps,
|
|
|
|
|
configData: new ConfigurationDataRecaptchaLogin())
|
|
|
|
|
{
|
|
|
|
|
Encoding = Encoding.GetEncoding("iso-8859-1");
|
|
|
|
|
Language = "en-us";
|
|
|
|
|
Type = "private";
|
|
|
|
|
|
|
|
|
|
AddCategoryMapping(0, TorznabCatType.Other);
|
|
|
|
|
AddCategoryMapping(48, TorznabCatType.Other); // 0Day
|
|
|
|
|
AddCategoryMapping(56, TorznabCatType.XXXImageset); // 0Day-Imagesets
|
|
|
|
|
AddCategoryMapping(6, TorznabCatType.Audio); // 0Day-Music
|
|
|
|
|
AddCategoryMapping(51, TorznabCatType.XXX); // 0Day-XXX
|
|
|
|
|
AddCategoryMapping(2, TorznabCatType.TVAnime); // Anime
|
|
|
|
|
AddCategoryMapping(59, TorznabCatType.MoviesBluRay); // BluRay
|
|
|
|
|
AddCategoryMapping(40, TorznabCatType.TVDocumentary); // Documentary
|
|
|
|
|
AddCategoryMapping(20, TorznabCatType.MoviesDVD); // DVD-R
|
|
|
|
|
AddCategoryMapping(25, TorznabCatType.BooksEbook); // Ebooks
|
|
|
|
|
AddCategoryMapping(38, TorznabCatType.PCPhoneIOS); // HandHeld
|
|
|
|
|
AddCategoryMapping(38, TorznabCatType.PCPhoneAndroid); // HandHeld
|
|
|
|
|
AddCategoryMapping(38, TorznabCatType.PCPhoneOther); // HandHeld
|
|
|
|
|
AddCategoryMapping(37, TorznabCatType.Other); // Kids Stuff
|
|
|
|
|
AddCategoryMapping(23, TorznabCatType.PC); // Linux
|
|
|
|
|
AddCategoryMapping(24, TorznabCatType.PCMac); // Mac
|
|
|
|
|
AddCategoryMapping(22, TorznabCatType.OtherMisc); // Misc
|
|
|
|
|
AddCategoryMapping(35, TorznabCatType.MoviesOther); // Movie Pack
|
|
|
|
|
AddCategoryMapping(36, TorznabCatType.MoviesHD); // Movie-HD
|
|
|
|
|
AddCategoryMapping(19, TorznabCatType.MoviesSD); // Movie-SD
|
|
|
|
|
AddCategoryMapping(50, TorznabCatType.Audio); // Music
|
|
|
|
|
AddCategoryMapping(53, TorznabCatType.AudioLossless); // Music-FLAC
|
|
|
|
|
AddCategoryMapping(49, TorznabCatType.AudioVideo); // MVID
|
|
|
|
|
AddCategoryMapping(1, TorznabCatType.PC); // PC Apps
|
|
|
|
|
AddCategoryMapping(4, TorznabCatType.PCGames); // PC Games
|
|
|
|
|
AddCategoryMapping(17, TorznabCatType.ConsolePS3); // Playstation
|
|
|
|
|
AddCategoryMapping(17, TorznabCatType.ConsolePS4); // Playstation
|
|
|
|
|
AddCategoryMapping(17, TorznabCatType.ConsolePSVita); // Playstation
|
|
|
|
|
AddCategoryMapping(17, TorznabCatType.ConsolePSP); // Playstation
|
|
|
|
|
AddCategoryMapping(28, TorznabCatType.ConsolePSP); // PSP
|
|
|
|
|
AddCategoryMapping(34, TorznabCatType.TVOTHER); // TV Pack
|
|
|
|
|
AddCategoryMapping(32, TorznabCatType.TVHD); // TV-HD
|
|
|
|
|
AddCategoryMapping(55, TorznabCatType.TVOTHER); // TV-HDRip
|
|
|
|
|
AddCategoryMapping(7, TorznabCatType.TVSD); // TV-SD
|
|
|
|
|
AddCategoryMapping(57, TorznabCatType.TVOTHER); // TV-SDRip
|
|
|
|
|
AddCategoryMapping(33, TorznabCatType.ConsoleWii); // WII
|
|
|
|
|
AddCategoryMapping(33, TorznabCatType.ConsoleWiiU); // WII
|
|
|
|
|
AddCategoryMapping(45, TorznabCatType.ConsoleXbox); // XBox
|
|
|
|
|
AddCategoryMapping(45, TorznabCatType.ConsoleXbox360); // XBox
|
|
|
|
|
AddCategoryMapping(45, TorznabCatType.ConsoleXBOX360DLC); // XBox
|
|
|
|
|
AddCategoryMapping(45, TorznabCatType.ConsoleXboxOne); // XBox
|
|
|
|
|
AddCategoryMapping(9, TorznabCatType.XXX); // XXX
|
|
|
|
|
AddCategoryMapping(52, TorznabCatType.XXXOther); // XXX-ISO
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override async Task<ConfigurationData> GetConfigurationForSetup()
|
|
|
|
|
{
|
|
|
|
|
var loginPage = await RequestStringWithCookies(LoginUrl, configData.CookieHeader.Value);
|
|
|
|
|
CQ cq = loginPage.Content;
|
|
|
|
|
string recaptchaSiteKey = cq.Find(".g-recaptcha").Attr("data-sitekey");
|
2017-09-14 13:00:33 +00:00
|
|
|
|
if (recaptchaSiteKey != null)
|
|
|
|
|
{
|
|
|
|
|
var result = this.configData;
|
|
|
|
|
result.CookieHeader.Value = loginPage.Cookies;
|
|
|
|
|
result.Captcha.SiteKey = recaptchaSiteKey;
|
|
|
|
|
result.Captcha.Version = "2";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var result = new ConfigurationDataBasicLogin();
|
|
|
|
|
result.SiteLink.Value = configData.SiteLink.Value;
|
|
|
|
|
result.Instructions.Value = configData.Instructions.Value;
|
|
|
|
|
result.Username.Value = configData.Username.Value;
|
|
|
|
|
result.Password.Value = configData.Password.Value;
|
|
|
|
|
result.CookieHeader.Value = loginPage.Cookies;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2017-04-15 08:45:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-28 05:31:38 +00:00
|
|
|
|
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
2017-04-15 08:45:10 +00:00
|
|
|
|
{
|
|
|
|
|
LoadValuesFromJson(configJson);
|
|
|
|
|
var pairs = new Dictionary<string, string> {
|
|
|
|
|
{ "returnto" , "/" },
|
|
|
|
|
{ "username", configData.Username.Value },
|
|
|
|
|
{ "password", configData.Password.Value },
|
|
|
|
|
{ "g-recaptcha-response", configData.Captcha.Value }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(configData.Captcha.Cookie))
|
|
|
|
|
{
|
|
|
|
|
// Cookie was manually supplied
|
|
|
|
|
CookieHeader = configData.Captcha.Cookie;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var results = await PerformQuery(new TorznabQuery());
|
|
|
|
|
if (!results.Any())
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Your cookie did not work");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IsConfigured = true;
|
2017-05-06 17:39:02 +00:00
|
|
|
|
SaveConfig();
|
2017-04-15 08:45:10 +00:00
|
|
|
|
return IndexerConfigurationStatus.Completed;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
IsConfigured = false;
|
|
|
|
|
throw new Exception("Your cookie did not work: " + e.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var result = await RequestLoginAndFollowRedirect(AjaxLoginUrl, pairs, configData.CookieHeader.Value, true, SiteLink, LoginUrl);
|
|
|
|
|
|
|
|
|
|
await ConfigureIfOK(result.Cookies, result.Content.Contains("logout.php"), () =>
|
|
|
|
|
{
|
2017-11-06 14:13:02 +00:00
|
|
|
|
CQ errorMessage = result.Content;
|
|
|
|
|
throw new ExceptionWithConfigData(errorMessage.Text(), configData);
|
2017-04-15 08:45:10 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return IndexerConfigurationStatus.RequiresTesting;
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-03 05:15:47 +00:00
|
|
|
|
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
2017-04-15 08:45:10 +00:00
|
|
|
|
{
|
|
|
|
|
List<ReleaseInfo> releases = new List<ReleaseInfo>();
|
|
|
|
|
|
|
|
|
|
var queryCollection = new NameValueCollection();
|
|
|
|
|
var searchString = query.GetQueryString();
|
|
|
|
|
var searchUrl = SearchUrl;
|
|
|
|
|
|
|
|
|
|
foreach (var cat in MapTorznabCapsToTrackers(query))
|
|
|
|
|
{
|
|
|
|
|
queryCollection.Add("c" + cat, "1");
|
|
|
|
|
}
|
2017-10-29 06:21:18 +00:00
|
|
|
|
|
2017-04-15 08:45:10 +00:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchString))
|
|
|
|
|
{
|
|
|
|
|
queryCollection.Add("search", searchString);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
queryCollection.Add("blah", "0");
|
|
|
|
|
|
|
|
|
|
var results = await RequestStringWithCookiesAndRetry(searchUrl + "?" + queryCollection.GetQueryString());
|
|
|
|
|
if (results.IsRedirect)
|
|
|
|
|
{
|
|
|
|
|
// re-login
|
|
|
|
|
await ApplyConfiguration(null);
|
|
|
|
|
results = await RequestStringWithCookiesAndRetry(searchUrl + "?" + queryCollection.GetQueryString());
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
releases.AddRange(contentToReleaseInfos(query, results.Content));
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
OnParseError(results.Content, ex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return releases;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IEnumerable<ReleaseInfo> contentToReleaseInfos(TorznabQuery query, CQ dom)
|
|
|
|
|
{
|
|
|
|
|
List<ReleaseInfo> releases = new List<ReleaseInfo>();
|
|
|
|
|
|
|
|
|
|
// Doesn't handle pagination yet...
|
|
|
|
|
var rows = dom["div.panel-body > table.table > tbody > tr"];
|
|
|
|
|
foreach (var row in rows)
|
|
|
|
|
{
|
|
|
|
|
var release = new ReleaseInfo();
|
|
|
|
|
release.MinimumRatio = 1;
|
|
|
|
|
release.MinimumSeedTime = 259200;
|
|
|
|
|
|
|
|
|
|
var qRow = row.Cq();
|
|
|
|
|
release.Title = qRow.Find("td:nth-child(2) > a").First().Text().Trim();
|
|
|
|
|
|
|
|
|
|
if ((query.ImdbID == null || !TorznabCaps.SupportsImdbSearch) && !query.MatchQueryStringAND(release.Title))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
release.Guid = new Uri(SiteLink + qRow.Find("td:nth-child(2) > a").First().Attr("href"));
|
|
|
|
|
release.Comments = release.Guid;
|
|
|
|
|
release.Link = new Uri(SiteLink + qRow.Find("td:nth-child(3) > a").First().Attr("href"));
|
2017-04-20 15:40:54 +00:00
|
|
|
|
var pubDateElement = qRow.Find("td:nth-child(2) > span").First();
|
|
|
|
|
pubDateElement.Find("a").Remove(); // remove snatchinfo links (added after completing a torrent)
|
|
|
|
|
var pubDate = pubDateElement.Text().Trim().Replace("Added: ", "");
|
2017-04-15 08:45:10 +00:00
|
|
|
|
release.PublishDate = DateTime.Parse(pubDate).ToLocalTime();
|
|
|
|
|
release.Category = MapTrackerCatToNewznab(qRow.Find("td:nth-child(1) > a").First().Attr("href").Split('=')[1]);
|
|
|
|
|
release.Size = ReleaseInfo.GetBytes(qRow.Find("td:nth-child(7)").First().Text());
|
|
|
|
|
release.Seeders = ParseUtil.CoerceInt(qRow.Find("td:nth-child(9)").First().Text());
|
|
|
|
|
release.Peers = ParseUtil.CoerceInt(qRow.Find("td:nth-child(10)").First().Text()) + release.Seeders;
|
|
|
|
|
|
|
|
|
|
var files = row.Cq().Find("td:nth-child(5)").Text();
|
|
|
|
|
release.Files = ParseUtil.CoerceInt(files);
|
|
|
|
|
|
|
|
|
|
var grabs = row.Cq().Find("td:nth-child(8)").Text();
|
|
|
|
|
release.Grabs = ParseUtil.CoerceInt(grabs);
|
|
|
|
|
|
|
|
|
|
if (row.Cq().Find("i.fa-star").Any())
|
|
|
|
|
release.DownloadVolumeFactor = 0;
|
|
|
|
|
else
|
|
|
|
|
release.DownloadVolumeFactor = 1;
|
|
|
|
|
|
|
|
|
|
release.UploadVolumeFactor = 1;
|
|
|
|
|
|
|
|
|
|
releases.Add(release);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return releases;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-16 14:09:49 +00:00
|
|
|
|
}
|