2020-06-21 09:22:49 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Specialized;
|
2020-05-03 23:35:52 +00:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2020-06-21 09:22:49 +00:00
|
|
|
using System.Linq;
|
|
|
|
using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using AngleSharp.Html.Parser;
|
2018-07-04 07:48:56 +00:00
|
|
|
using Jackett.Common.Models;
|
2020-06-21 09:22:49 +00:00
|
|
|
using Jackett.Common.Models.IndexerConfig;
|
2018-07-04 07:48:56 +00:00
|
|
|
using Jackett.Common.Services.Interfaces;
|
2020-06-21 09:22:49 +00:00
|
|
|
using Jackett.Common.Utils;
|
2018-07-04 07:48:56 +00:00
|
|
|
using Jackett.Common.Utils.Clients;
|
2020-06-21 09:22:49 +00:00
|
|
|
using Newtonsoft.Json.Linq;
|
2018-07-04 07:48:56 +00:00
|
|
|
using NLog;
|
|
|
|
|
|
|
|
namespace Jackett.Common.Indexers
|
|
|
|
{
|
2020-06-21 09:22:49 +00:00
|
|
|
// This tracker is based on GazelleTracker but we can't use the API/abstract because there are some
|
|
|
|
// missing features. https://github.com/Jackett/Jackett/issues/7923
|
2020-05-03 23:35:52 +00:00
|
|
|
[ExcludeFromCodeCoverage]
|
2020-06-21 09:22:49 +00:00
|
|
|
public class Anthelion : BaseWebIndexer
|
2018-07-04 07:48:56 +00:00
|
|
|
{
|
2020-06-21 09:22:49 +00:00
|
|
|
private string LoginUrl => SiteLink + "login.php";
|
|
|
|
private string BrowseUrl => SiteLink + "torrents.php";
|
|
|
|
|
|
|
|
private new ConfigurationDataBasicLogin configData => (ConfigurationDataBasicLogin)base.configData;
|
|
|
|
|
2020-05-15 21:50:04 +00:00
|
|
|
public override string[] LegacySiteLinks { get; protected set; } = {
|
2018-10-04 17:54:39 +00:00
|
|
|
"https://tehconnection.me/",
|
|
|
|
};
|
|
|
|
|
2020-05-11 19:59:28 +00:00
|
|
|
public Anthelion(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
|
2020-05-15 21:50:04 +00:00
|
|
|
: base(id: "anthelion",
|
2020-05-11 19:59:28 +00:00
|
|
|
name: "Anthelion", // old name: TehConnection.me
|
2020-04-04 06:56:51 +00:00
|
|
|
description: "A movies tracker",
|
|
|
|
link: "https://anthelion.me/",
|
2020-10-18 17:26:22 +00:00
|
|
|
caps: new TorznabCapabilities {
|
|
|
|
MovieSearchParams = new List<MovieSearchParam> { MovieSearchParam.Q }
|
|
|
|
},
|
2020-04-04 06:56:51 +00:00
|
|
|
configService: configService,
|
|
|
|
client: wc,
|
|
|
|
logger: l,
|
|
|
|
p: ps,
|
2020-06-21 09:22:49 +00:00
|
|
|
configData: new ConfigurationDataBasicLogin())
|
2018-07-04 07:48:56 +00:00
|
|
|
{
|
2020-06-21 09:22:49 +00:00
|
|
|
Encoding = Encoding.UTF8;
|
2018-07-04 07:48:56 +00:00
|
|
|
Language = "en-us";
|
|
|
|
Type = "private";
|
|
|
|
|
2020-06-21 09:22:49 +00:00
|
|
|
AddCategoryMapping("1", TorznabCatType.Movies, "Feature Film");
|
|
|
|
AddCategoryMapping("2", TorznabCatType.Movies, "Short Film");
|
|
|
|
AddCategoryMapping("3", TorznabCatType.TV, "Miniseries");
|
|
|
|
AddCategoryMapping("4", TorznabCatType.Other, "Other");
|
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
|
|
|
{
|
|
|
|
LoadValuesFromJson(configJson);
|
|
|
|
|
|
|
|
var pairs = new Dictionary<string, string>
|
|
|
|
{
|
|
|
|
{ "username", configData.Username.Value },
|
|
|
|
{ "password", configData.Password.Value },
|
|
|
|
{ "keeplogged", "1" },
|
|
|
|
{ "login", "Log+In!" }
|
|
|
|
};
|
|
|
|
|
|
|
|
var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, null, true, null, LoginUrl, true);
|
2020-06-09 17:36:57 +00:00
|
|
|
await ConfigureIfOK(result.Cookies, result.ContentString?.Contains("logout.php") == true, () =>
|
2020-06-21 09:22:49 +00:00
|
|
|
{
|
|
|
|
var parser = new HtmlParser();
|
2020-06-09 17:36:57 +00:00
|
|
|
var dom = parser.ParseDocument(result.ContentString);
|
2020-06-21 09:22:49 +00:00
|
|
|
var errorMessage = dom.QuerySelector("form#loginform").TextContent.Trim();
|
|
|
|
throw new ExceptionWithConfigData(errorMessage, configData);
|
|
|
|
});
|
|
|
|
return IndexerConfigurationStatus.RequiresTesting;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
|
|
|
{
|
|
|
|
var releases = new List<ReleaseInfo>();
|
|
|
|
|
|
|
|
// TODO: IMDB search is available but it requires to parse the details page
|
|
|
|
var qc = new NameValueCollection
|
|
|
|
{
|
|
|
|
{ "order_by", "time" },
|
|
|
|
{ "order_way", "desc" },
|
|
|
|
{ "action", "basic" },
|
|
|
|
{ "searchsubmit", "1" },
|
|
|
|
{ "searchstr", query.IsImdbQuery ? query.ImdbID : query.GetQueryString() }
|
|
|
|
};
|
|
|
|
|
|
|
|
var catList = MapTorznabCapsToTrackers(query);
|
|
|
|
foreach (var cat in catList)
|
|
|
|
qc.Add($"filter_cat[{cat}]", "1");
|
|
|
|
|
|
|
|
var searchUrl = BrowseUrl + "?" + qc.GetQueryString();
|
2020-09-21 16:39:47 +00:00
|
|
|
var results = await RequestWithCookiesAsync(searchUrl);
|
2020-06-21 09:22:49 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
var parser = new HtmlParser();
|
2020-06-09 17:36:57 +00:00
|
|
|
var doc = parser.ParseDocument(results.ContentString);
|
2020-06-21 09:22:49 +00:00
|
|
|
var rows = doc.QuerySelectorAll("table.torrent_table > tbody > tr.torrent");
|
|
|
|
foreach (var row in rows)
|
|
|
|
{
|
|
|
|
var qDetailsLink = row.QuerySelector("a.torrent_name");
|
|
|
|
var year = qDetailsLink.NextSibling.TextContent.Replace("[", "").Replace("]", "").Trim();
|
|
|
|
var tags = row.QuerySelector("div.torrent_info").FirstChild.TextContent.Replace(" / ", " ").Trim();
|
|
|
|
var title = $"{qDetailsLink.TextContent} {year} {tags}";
|
|
|
|
var description = row.QuerySelector("div.tags").TextContent.Trim();
|
|
|
|
var comments = new Uri(SiteLink + qDetailsLink.GetAttribute("href"));
|
|
|
|
var torrentId = qDetailsLink.GetAttribute("href").Split('=').Last();
|
|
|
|
var link = new Uri(SiteLink + "torrents.php?action=download&id=" + torrentId);
|
|
|
|
var bannerStr = qDetailsLink.GetAttribute("data-cover");
|
|
|
|
var banner = !string.IsNullOrWhiteSpace(bannerStr) ? new Uri(qDetailsLink.GetAttribute("data-cover")) : null;
|
|
|
|
|
|
|
|
var files = ParseUtil.CoerceLong(row.QuerySelector("td:nth-child(3)").TextContent);
|
|
|
|
var publishDate = DateTimeUtil.FromTimeAgo(row.QuerySelector("td:nth-child(4)").TextContent);
|
|
|
|
var size = ReleaseInfo.GetBytes(row.QuerySelector("td:nth-child(5)").FirstChild.TextContent);
|
|
|
|
var grabs = ParseUtil.CoerceLong(row.QuerySelector("td:nth-child(6)").TextContent);
|
|
|
|
var seeders = ParseUtil.CoerceInt(row.QuerySelector("td:nth-child(7)").TextContent);
|
|
|
|
var leechers = ParseUtil.CoerceInt(row.QuerySelector("td:nth-child(8)").TextContent);
|
|
|
|
|
|
|
|
var dlVolumeFactor = row.QuerySelector("strong.tl_free") != null ? 0 : 1;
|
|
|
|
|
|
|
|
var cat = row.QuerySelector("td.cats_col > div").GetAttribute("class").Replace("tooltip cats_", "");
|
|
|
|
var category = new List<int> {
|
|
|
|
cat switch
|
|
|
|
{
|
|
|
|
"featurefilm" => TorznabCatType.Movies.ID,
|
|
|
|
"shortfilm" => TorznabCatType.Movies.ID,
|
|
|
|
"miniseries" => TorznabCatType.TV.ID,
|
|
|
|
"other" => TorznabCatType.Other.ID,
|
|
|
|
_ => throw new Exception($"Unknown category: {cat}")
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// TODO: TMDb is also available
|
|
|
|
var qImdb = row.QuerySelector("a[href^=\"https://www.imdb.com\"]");
|
|
|
|
var imdb = qImdb != null ? ParseUtil.GetImdbID(qImdb.GetAttribute("href").Split('/').Last()) : null;
|
|
|
|
|
|
|
|
var release = new ReleaseInfo
|
|
|
|
{
|
|
|
|
MinimumRatio = 1,
|
2020-09-29 04:27:45 +00:00
|
|
|
MinimumSeedTime = 259200,
|
2020-06-21 09:22:49 +00:00
|
|
|
Description = description,
|
|
|
|
Title = title,
|
|
|
|
PublishDate = publishDate,
|
|
|
|
Category = category,
|
|
|
|
Link = link,
|
|
|
|
Comments = comments,
|
|
|
|
Guid = link,
|
|
|
|
Imdb = imdb,
|
|
|
|
BannerUrl = banner,
|
|
|
|
Seeders = seeders,
|
|
|
|
Peers = leechers + seeders,
|
|
|
|
Size = size,
|
|
|
|
Grabs = grabs,
|
|
|
|
Files = files,
|
|
|
|
DownloadVolumeFactor = dlVolumeFactor,
|
|
|
|
UploadVolumeFactor = 1
|
|
|
|
};
|
|
|
|
releases.Add(release);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
2020-06-09 17:36:57 +00:00
|
|
|
OnParseError(results.ContentString, ex);
|
2020-06-21 09:22:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return releases;
|
2018-07-04 07:48:56 +00:00
|
|
|
}
|
|
|
|
}
|
2020-02-09 02:35:16 +00:00
|
|
|
}
|