2020-02-09 02:35:16 +00:00
|
|
|
using System;
|
2016-09-22 10:27:35 +00:00
|
|
|
using System.Collections.Generic;
|
2017-04-15 08:45:10 +00:00
|
|
|
using System.Collections.Specialized;
|
2017-10-29 06:50:47 +00:00
|
|
|
using System.Globalization;
|
2017-04-15 08:45:10 +00:00
|
|
|
using System.Linq;
|
2017-10-29 06:50:47 +00:00
|
|
|
using System.Text;
|
2017-04-15 08:45:10 +00:00
|
|
|
using System.Text.RegularExpressions;
|
2017-10-29 06:50:47 +00:00
|
|
|
using System.Threading.Tasks;
|
2020-02-29 19:42:31 +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:50:47 +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
|
2016-09-22 10:27:35 +00:00
|
|
|
{
|
2017-07-10 20:58:44 +00:00
|
|
|
public class TorrentHeaven : BaseWebIndexer
|
2016-09-22 10:27:35 +00:00
|
|
|
{
|
2020-03-11 05:20:53 +00:00
|
|
|
public override string[] LegacySiteLinks { get; protected set; } =
|
|
|
|
{
|
|
|
|
"https://torrentheaven.myfqdn.info/"
|
2020-02-09 02:35:16 +00:00
|
|
|
};
|
2019-04-13 13:52:00 +00:00
|
|
|
|
2020-02-25 16:08:03 +00:00
|
|
|
private string IndexUrl => SiteLink + "index.php";
|
2020-03-11 05:20:53 +00:00
|
|
|
|
|
|
|
private string LoginCompleteUrl =>
|
|
|
|
SiteLink + "index.php?strWebValue=account&strWebAction=login_complete&ancestry=verify";
|
2016-09-22 10:27:35 +00:00
|
|
|
|
2017-10-29 06:50:47 +00:00
|
|
|
private new ConfigurationDataCaptchaLogin configData
|
2016-09-22 10:27:35 +00:00
|
|
|
{
|
2020-02-25 16:08:03 +00:00
|
|
|
get => (ConfigurationDataCaptchaLogin)base.configData;
|
|
|
|
set => base.configData = value;
|
2016-09-22 10:27:35 +00:00
|
|
|
}
|
|
|
|
|
2020-03-11 05:20:53 +00:00
|
|
|
public TorrentHeaven(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) :
|
|
|
|
base(
|
|
|
|
name: "TorrentHeaven",
|
|
|
|
description: "A German general tracker.",
|
|
|
|
link: "https://newheaven.nl/",
|
|
|
|
caps: TorznabUtil.CreateDefaultTorznabTVCaps(),
|
|
|
|
configService: configService,
|
|
|
|
client: wc,
|
|
|
|
logger: l,
|
|
|
|
p: ps,
|
|
|
|
configData: new ConfigurationDataCaptchaLogin())
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2016-12-06 13:56:47 +00:00
|
|
|
Encoding = Encoding.GetEncoding("iso-8859-1");
|
2016-12-09 17:20:58 +00:00
|
|
|
Language = "de-de";
|
2017-01-27 15:57:32 +00:00
|
|
|
Type = "private";
|
2020-03-11 05:20:53 +00:00
|
|
|
// incomplete CA chain
|
|
|
|
wc.AddTrustedCertificate(new Uri(SiteLink).Host, "cbf23ac75b07255ad7548a87567a839d23f31576");
|
2018-03-05 12:34:55 +00:00
|
|
|
AddCategoryMapping(1, TorznabCatType.PCGames, "GAMES/PC");
|
|
|
|
AddCategoryMapping(3, TorznabCatType.Console, "GAMES/Sonstige");
|
|
|
|
AddCategoryMapping(59, TorznabCatType.ConsolePS4, "GAMES/PlayStation");
|
|
|
|
AddCategoryMapping(60, TorznabCatType.ConsolePSP, "GAMES/PSP");
|
|
|
|
AddCategoryMapping(63, TorznabCatType.ConsoleWii, "GAMES/Wii");
|
|
|
|
AddCategoryMapping(67, TorznabCatType.ConsoleXbox360, "GAMES/XBOX 360");
|
|
|
|
AddCategoryMapping(68, TorznabCatType.PCPhoneOther, "GAMES/PDA / Handy");
|
|
|
|
AddCategoryMapping(72, TorznabCatType.ConsoleNDS, "GAMES/NDS");
|
|
|
|
AddCategoryMapping(7, TorznabCatType.MoviesDVD, "MOVIES/DVD");
|
|
|
|
AddCategoryMapping(8, TorznabCatType.MoviesSD, "MOVIES/SD");
|
|
|
|
AddCategoryMapping(37, TorznabCatType.MoviesDVD, "MOVIES/DVD Spezial");
|
|
|
|
AddCategoryMapping(41, TorznabCatType.MoviesForeign, "MOVIES/International");
|
|
|
|
AddCategoryMapping(101, TorznabCatType.MoviesHD, "MOVIES/720p");
|
|
|
|
AddCategoryMapping(102, TorznabCatType.MoviesHD, "MOVIES/1080p");
|
|
|
|
AddCategoryMapping(103, TorznabCatType.MoviesHD, "MOVIES/AVCHD");
|
|
|
|
AddCategoryMapping(104, TorznabCatType.MoviesBluRay, "MOVIES/Bluray");
|
|
|
|
AddCategoryMapping(106, TorznabCatType.Movies3D, "MOVIES/3D");
|
|
|
|
AddCategoryMapping(109, TorznabCatType.MoviesUHD, "MOVIES/4K");
|
|
|
|
AddCategoryMapping(14, TorznabCatType.Audio, "AUDIO/Musik");
|
|
|
|
AddCategoryMapping(15, TorznabCatType.AudioAudiobook, "AUDIO/Hörbücher");
|
|
|
|
AddCategoryMapping(16, TorznabCatType.AudioAudiobook, "AUDIO/Hörspiele");
|
|
|
|
AddCategoryMapping(36, TorznabCatType.AudioLossless, "AUDIO/Flac");
|
|
|
|
AddCategoryMapping(42, TorznabCatType.AudioOther, "AUDIO/Soundtracks");
|
|
|
|
AddCategoryMapping(58, TorznabCatType.AudioVideo, "AUDIO/Musikvideos");
|
|
|
|
AddCategoryMapping(18, TorznabCatType.TVSD, "TV/Serien SD");
|
|
|
|
AddCategoryMapping(19, TorznabCatType.TVHD, "TV/Serien HD 720p");
|
|
|
|
AddCategoryMapping(20, TorznabCatType.TVHD, "TV/Serien HD 1080p");
|
|
|
|
AddCategoryMapping(49, TorznabCatType.TVSD, "TV/Serien DVD");
|
|
|
|
AddCategoryMapping(51, TorznabCatType.TVDocumentary, "TV/Doku SD");
|
|
|
|
AddCategoryMapping(52, TorznabCatType.TVDocumentary, "TV/Doku HD");
|
|
|
|
AddCategoryMapping(53, TorznabCatType.TV, "TV/Serien Complete Packs");
|
|
|
|
AddCategoryMapping(54, TorznabCatType.TVSport, "TV/Sport");
|
|
|
|
AddCategoryMapping(66, TorznabCatType.TVFOREIGN, "TV/International");
|
|
|
|
AddCategoryMapping(22, TorznabCatType.Books, "MISC/EBooks");
|
|
|
|
AddCategoryMapping(24, TorznabCatType.Other, "MISC/Sonstiges");
|
|
|
|
AddCategoryMapping(25, TorznabCatType.Other, "MISC/Tonspuren");
|
|
|
|
AddCategoryMapping(108, TorznabCatType.TVAnime, "MISC/Anime");
|
|
|
|
AddCategoryMapping(28, TorznabCatType.PC, "APPLICATIONS/PC");
|
|
|
|
AddCategoryMapping(29, TorznabCatType.PCPhoneOther, "APPLICATIONS/Mobile");
|
|
|
|
AddCategoryMapping(30, TorznabCatType.PC, "APPLICATIONS/Sonstige");
|
|
|
|
AddCategoryMapping(70, TorznabCatType.PC, "APPLICATIONS/Linux");
|
|
|
|
AddCategoryMapping(71, TorznabCatType.PCMac, "APPLICATIONS/Mac");
|
2017-02-28 19:05:57 +00:00
|
|
|
}
|
|
|
|
|
2016-09-22 10:27:35 +00:00
|
|
|
public override async Task<ConfigurationData> GetConfigurationForSetup()
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
|
|
|
var loginPage = await RequestStringWithCookies(IndexUrl, string.Empty);
|
2020-02-29 19:42:31 +00:00
|
|
|
var parser = new HtmlParser();
|
|
|
|
var dom = parser.ParseDocument(loginPage.Content);
|
|
|
|
var qCaptchaImg = dom.QuerySelector("td.tablea > img");
|
|
|
|
if (qCaptchaImg != null)
|
2017-07-10 20:58:44 +00:00
|
|
|
{
|
2020-02-29 19:42:31 +00:00
|
|
|
var captchaUrl = SiteLink + qCaptchaImg.GetAttribute("src");
|
|
|
|
var captchaImage = await RequestBytesWithCookies(captchaUrl, loginPage.Cookies);
|
2017-04-15 08:45:10 +00:00
|
|
|
configData.CaptchaImage.Value = captchaImage.Content;
|
2016-09-22 10:27:35 +00:00
|
|
|
}
|
2017-04-15 08:45:10 +00:00
|
|
|
else
|
2020-03-11 05:20:53 +00:00
|
|
|
configData.CaptchaImage.Value = Array.Empty<byte>();
|
|
|
|
|
2016-09-22 10:27:35 +00:00
|
|
|
configData.CaptchaCookie.Value = loginPage.Cookies;
|
|
|
|
return configData;
|
|
|
|
}
|
|
|
|
|
2017-06-28 05:31:38 +00:00
|
|
|
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
2016-09-22 10:27:35 +00:00
|
|
|
{
|
2017-01-02 20:39:28 +00:00
|
|
|
LoadValuesFromJson(configJson);
|
2016-09-22 10:27:35 +00:00
|
|
|
var pairs = new Dictionary<string, string>
|
|
|
|
{
|
2020-03-11 05:20:53 +00:00
|
|
|
{"strWebAction", "login"},
|
|
|
|
{"strWebValue", "account"},
|
|
|
|
{"jsenabled", "1"},
|
|
|
|
{"screenwidth", "2560"},
|
|
|
|
{"username", configData.Username.Value},
|
|
|
|
{"password", configData.Password.Value}
|
2016-09-22 10:27:35 +00:00
|
|
|
};
|
2017-04-15 08:45:10 +00:00
|
|
|
if (!string.IsNullOrWhiteSpace(configData.CaptchaText.Value))
|
|
|
|
pairs.Add("proofcode", configData.CaptchaText.Value);
|
2020-03-11 05:20:53 +00:00
|
|
|
var result = await RequestLoginAndFollowRedirect(IndexUrl, pairs, configData.CaptchaCookie.Value, true, referer: IndexUrl, accumulateCookies: true);
|
|
|
|
if (result.Content == null || (!result.Content.Contains("login_complete") &&
|
|
|
|
!result.Content.Contains("index.php?strWebValue=account&strWebAction=logout")))
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2020-02-29 19:42:31 +00:00
|
|
|
var parser = new HtmlParser();
|
|
|
|
var dom = parser.ParseDocument(result.Content);
|
|
|
|
var errorMessageEl = dom.QuerySelector("table > tbody > tr > td[valign=top][width=100%]");
|
|
|
|
var errorMessage = errorMessageEl != null ? errorMessageEl.InnerHtml : result.Content;
|
2017-04-15 08:45:10 +00:00
|
|
|
throw new ExceptionWithConfigData(errorMessage, configData);
|
2016-09-22 10:27:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var result2 = await RequestStringWithCookies(LoginCompleteUrl, result.Cookies);
|
2020-03-11 05:20:53 +00:00
|
|
|
await ConfigureIfOK(
|
|
|
|
result2.Cookies, result2.Cookies?.Contains("pass") == true,
|
|
|
|
() => throw new ExceptionWithConfigData("Didn't get a user/pass cookie", configData));
|
2016-09-22 10:27:35 +00:00
|
|
|
return IndexerConfigurationStatus.RequiresTesting;
|
|
|
|
}
|
|
|
|
|
2017-07-03 05:15:47 +00:00
|
|
|
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
2016-09-22 10:27:35 +00:00
|
|
|
{
|
2020-03-11 05:20:53 +00:00
|
|
|
var startTransition = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(
|
|
|
|
new DateTime(1, 1, 1, 3, 0, 0), 3, 5, DayOfWeek.Sunday);
|
|
|
|
var endTransition = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(
|
|
|
|
new DateTime(1, 1, 1, 4, 0, 0), 10, 5, DayOfWeek.Sunday);
|
2020-02-10 22:16:19 +00:00
|
|
|
var delta = new TimeSpan(1, 0, 0);
|
2020-03-11 05:20:53 +00:00
|
|
|
var adjustment = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(
|
|
|
|
new DateTime(1999, 10, 1), DateTime.MaxValue.Date, delta, startTransition,
|
|
|
|
endTransition);
|
|
|
|
TimeZoneInfo.AdjustmentRule[] adjustments =
|
|
|
|
{
|
|
|
|
adjustment
|
|
|
|
};
|
|
|
|
var germanyTz = TimeZoneInfo.CreateCustomTimeZone(
|
|
|
|
"W. Europe Standard Time", new TimeSpan(1, 0, 0), "(GMT+01:00) W. Europe Standard Time",
|
|
|
|
"W. Europe Standard Time", "W. Europe DST Time", adjustments);
|
2016-09-22 10:27:35 +00:00
|
|
|
var releases = new List<ReleaseInfo>();
|
2017-04-15 08:45:10 +00:00
|
|
|
var searchString = query.GetQueryString();
|
|
|
|
var searchUrl = IndexUrl;
|
2020-03-11 05:20:53 +00:00
|
|
|
var queryCollection = new NameValueCollection
|
2020-03-10 17:05:57 +00:00
|
|
|
{
|
2020-03-11 05:20:53 +00:00
|
|
|
{"strWebValue", "torrent"},
|
|
|
|
{"strWebAction", "search"},
|
|
|
|
{"sort", "torrent_added"},
|
|
|
|
{"by", "d"},
|
|
|
|
{"type", "0"},
|
|
|
|
{"do_search", "suchen"},
|
|
|
|
{"time", "0"},
|
|
|
|
{"details", "title"}
|
|
|
|
};
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchString))
|
2017-04-15 08:45:10 +00:00
|
|
|
queryCollection.Add("searchstring", searchString);
|
|
|
|
foreach (var cat in MapTorznabCapsToTrackers(query))
|
|
|
|
queryCollection.Add("dirs" + cat, "1");
|
2016-09-22 10:27:35 +00:00
|
|
|
searchUrl += "?" + queryCollection.GetQueryString();
|
2016-12-06 13:56:47 +00:00
|
|
|
var response = await RequestStringWithCookies(searchUrl);
|
2020-03-11 05:20:53 +00:00
|
|
|
var titleRegexp = new Regex(@"^return buildTable\('(.*?)',\s+");
|
2016-09-22 10:27:35 +00:00
|
|
|
try
|
|
|
|
{
|
2020-02-29 19:42:31 +00:00
|
|
|
var parser = new HtmlParser();
|
|
|
|
var dom = parser.ParseDocument(response.Content);
|
|
|
|
var rows = dom.QuerySelectorAll("table.torrenttable > tbody > tr");
|
2016-09-22 10:27:35 +00:00
|
|
|
foreach (var row in rows.Skip(1))
|
|
|
|
{
|
|
|
|
var release = new ReleaseInfo();
|
2017-04-15 08:45:10 +00:00
|
|
|
release.MinimumRatio = 0.8;
|
2016-09-22 10:27:35 +00:00
|
|
|
release.MinimumSeedTime = 0;
|
2020-03-02 07:45:31 +00:00
|
|
|
var qDetailsLink = row.QuerySelector("a[href^=\"index.php?strWebValue=torrent&strWebAction=details\"]");
|
2020-03-11 05:20:53 +00:00
|
|
|
release.Title = titleRegexp.Match(qDetailsLink.GetAttribute("onmouseover")).Groups[1].Value;
|
2020-03-02 07:45:31 +00:00
|
|
|
var qCatLink = row.QuerySelector("a[href^=\"index.php?strWebValue=torrent&strWebAction=search&dir=\"]");
|
|
|
|
var qDlLink = row.QuerySelector("a[href^=\"index.php?strWebValue=torrent&strWebAction=download&id=\"]");
|
2020-03-11 05:20:53 +00:00
|
|
|
var qSeeders = row.QuerySelectorAll("td.column1")[3];
|
|
|
|
var qLeechers = row.QuerySelectorAll("td.column2")[3];
|
2020-02-29 19:42:31 +00:00
|
|
|
var qDateStr = row.QuerySelector("font:has(a)");
|
|
|
|
var qSize = row.QuerySelector("td.column2[align=center]");
|
|
|
|
var catStr = qCatLink.GetAttribute("href").Split('=')[3].Split('#')[0];
|
2017-04-15 08:45:10 +00:00
|
|
|
release.Category = MapTrackerCatToNewznab(catStr);
|
2020-02-29 19:42:31 +00:00
|
|
|
release.Link = new Uri(SiteLink + qDlLink.GetAttribute("href"));
|
|
|
|
release.Comments = new Uri(SiteLink + qDetailsLink.GetAttribute("href"));
|
2017-04-15 08:45:10 +00:00
|
|
|
release.Guid = release.Link;
|
2020-03-11 05:20:53 +00:00
|
|
|
var sizeStr = qSize.TextContent;
|
2017-04-15 08:45:10 +00:00
|
|
|
release.Size = ReleaseInfo.GetBytes(sizeStr);
|
2020-02-29 19:42:31 +00:00
|
|
|
release.Seeders = ParseUtil.CoerceInt(qSeeders.TextContent);
|
|
|
|
release.Peers = ParseUtil.CoerceInt(qLeechers.TextContent) + release.Seeders;
|
2020-03-11 05:20:53 +00:00
|
|
|
var dateStr = qDateStr.TextContent.Trim();
|
2016-09-22 10:27:35 +00:00
|
|
|
var dateStrParts = dateStr.Split();
|
2020-03-11 05:20:53 +00:00
|
|
|
var dateGerman = dateStrParts[0] switch
|
|
|
|
{
|
|
|
|
"Heute" => (DateTime.SpecifyKind(DateTime.UtcNow.Date, DateTimeKind.Unspecified) + TimeSpan.Parse(dateStrParts[1])),
|
|
|
|
"Gestern" => (DateTime.SpecifyKind(DateTime.UtcNow.Date, DateTimeKind.Unspecified) + TimeSpan.Parse(dateStrParts[1])
|
|
|
|
- TimeSpan.FromDays(1)),
|
|
|
|
_ => DateTime.SpecifyKind( DateTime.ParseExact(
|
|
|
|
dateStrParts[0] + dateStrParts[1], "dd.MM.yyyyHH:mm", CultureInfo.InvariantCulture),
|
|
|
|
DateTimeKind.Unspecified)
|
|
|
|
};
|
|
|
|
|
|
|
|
release.PublishDate = TimeZoneInfo.ConvertTime(dateGerman, germanyTz, TimeZoneInfo.Local);
|
2020-02-29 19:42:31 +00:00
|
|
|
var grabs = row.QuerySelector("td:nth-child(7)").TextContent;
|
2017-04-15 08:45:10 +00:00
|
|
|
release.Grabs = ParseUtil.CoerceInt(grabs);
|
2020-03-11 05:20:53 +00:00
|
|
|
if (row.QuerySelector("img[src=\"themes/images/freeleech.png\"]") != null
|
|
|
|
|| row.QuerySelector("img[src=\"themes/images/onlyup.png\"]") != null)
|
2016-10-27 07:35:31 +00:00
|
|
|
release.DownloadVolumeFactor = 0;
|
2020-02-29 19:42:31 +00:00
|
|
|
else if (row.QuerySelector("img[src=\"themes/images/DL50.png\"]") != null)
|
2017-04-15 08:45:10 +00:00
|
|
|
release.DownloadVolumeFactor = 0.5;
|
2016-10-27 07:35:31 +00:00
|
|
|
else
|
2017-04-15 08:45:10 +00:00
|
|
|
release.DownloadVolumeFactor = 1;
|
2016-10-27 07:35:31 +00:00
|
|
|
release.UploadVolumeFactor = 1;
|
2016-09-22 10:27:35 +00:00
|
|
|
releases.Add(release);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
2020-02-29 19:42:31 +00:00
|
|
|
OnParseError(response.Content, ex);
|
2016-09-22 10:27:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return releases;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|