2020-02-09 02:35:16 +00:00
|
|
|
using System;
|
2016-11-19 10:33:00 +00:00
|
|
|
using System.Collections.Generic;
|
2017-04-15 08:45:10 +00:00
|
|
|
using System.Collections.Specialized;
|
2020-05-03 23:35:52 +00:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2020-06-14 11:39:04 +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;
|
2019-01-20 00:09:27 +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-11-19 10:33:00 +00:00
|
|
|
{
|
2020-06-21 07:57:44 +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/8508
|
2020-05-03 23:35:52 +00:00
|
|
|
[ExcludeFromCodeCoverage]
|
2017-07-10 20:58:44 +00:00
|
|
|
public class TVVault : BaseWebIndexer
|
2016-11-19 10:33:00 +00:00
|
|
|
{
|
2020-02-25 16:08:03 +00:00
|
|
|
private string LoginUrl => SiteLink + "login.php";
|
|
|
|
private string BrowseUrl => SiteLink + "torrents.php";
|
2016-11-19 10:33:00 +00:00
|
|
|
|
2020-06-14 11:39:04 +00:00
|
|
|
private new ConfigurationDataBasicLogin configData => (ConfigurationDataBasicLogin)base.configData;
|
2016-11-19 10:33:00 +00:00
|
|
|
|
2017-11-05 09:42:03 +00:00
|
|
|
public TVVault(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
|
2020-05-11 19:59:28 +00:00
|
|
|
: base(id: "tvvault",
|
|
|
|
name: "TV-Vault",
|
2020-06-14 11:39:04 +00:00
|
|
|
description: "A TV tracker for old shows",
|
2016-11-19 10:33:00 +00:00
|
|
|
link: "https://tv-vault.me/",
|
2020-06-14 11:39:04 +00:00
|
|
|
caps: new TorznabCapabilities
|
|
|
|
{
|
|
|
|
SupportsImdbMovieSearch = true
|
|
|
|
// SupportsImdbTVSearch = true (supported by the site but disabled due to #8107)
|
|
|
|
},
|
2017-07-10 20:58:44 +00:00
|
|
|
configService: configService,
|
2016-11-19 10:33:00 +00:00
|
|
|
client: wc,
|
|
|
|
logger: l,
|
|
|
|
p: ps,
|
2020-06-14 11:39:04 +00:00
|
|
|
configData: new ConfigurationDataBasicLogin())
|
2016-11-19 10:33:00 +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";
|
2016-12-06 13:56:47 +00:00
|
|
|
|
2016-11-19 10:33:00 +00:00
|
|
|
AddCategoryMapping(1, TorznabCatType.TV);
|
|
|
|
AddCategoryMapping(2, TorznabCatType.Movies);
|
|
|
|
}
|
|
|
|
|
2017-06-28 05:31:38 +00:00
|
|
|
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
2016-11-19 10:33:00 +00:00
|
|
|
{
|
2017-01-02 20:39:28 +00:00
|
|
|
LoadValuesFromJson(configJson);
|
2016-11-19 10:33:00 +00:00
|
|
|
|
|
|
|
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 07:57:44 +00:00
|
|
|
{
|
|
|
|
var parser = new HtmlParser();
|
2020-06-09 17:36:57 +00:00
|
|
|
var dom = parser.ParseDocument(result.ContentString);
|
2020-06-21 07:57:44 +00:00
|
|
|
var errorMessage = dom.QuerySelector("form#loginform").TextContent.Trim();
|
|
|
|
throw new ExceptionWithConfigData(errorMessage, configData);
|
|
|
|
});
|
2016-11-19 10:33:00 +00:00
|
|
|
return IndexerConfigurationStatus.RequiresTesting;
|
|
|
|
}
|
|
|
|
|
2017-07-03 05:15:47 +00:00
|
|
|
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
2016-11-19 10:33:00 +00:00
|
|
|
{
|
|
|
|
var releases = new List<ReleaseInfo>();
|
2017-10-29 06:50:47 +00:00
|
|
|
|
2020-06-14 11:39:04 +00:00
|
|
|
var qc = new NameValueCollection
|
2020-03-26 22:15:28 +00:00
|
|
|
{
|
|
|
|
{ "order_by", "s3" },
|
|
|
|
{ "order_way", "desc" },
|
|
|
|
{ "disablegrouping", "1" }
|
|
|
|
};
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2020-06-14 11:39:04 +00:00
|
|
|
if (query.IsImdbQuery)
|
|
|
|
{
|
|
|
|
qc.Add("action", "advanced");
|
|
|
|
qc.Add("imdbid", query.ImdbID);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
qc.Add("searchstr", StripSearchString(query.GetQueryString()));
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2020-06-14 11:39:04 +00:00
|
|
|
var searchUrl = BrowseUrl + "?" + qc.GetQueryString();
|
2020-09-21 16:39:47 +00:00
|
|
|
var results = await RequestWithCookiesAsync(searchUrl);
|
2016-11-19 10:33:00 +00:00
|
|
|
try
|
|
|
|
{
|
2020-06-14 11:39:04 +00:00
|
|
|
var seasonRegEx = new Regex(@$"Season\s+0*{query.Season}[^\d]", RegexOptions.IgnoreCase);
|
2016-11-19 10:33:00 +00:00
|
|
|
|
2020-06-14 11:39:04 +00:00
|
|
|
var parser = new HtmlParser();
|
2020-06-09 17:36:57 +00:00
|
|
|
var doc = parser.ParseDocument(results.ContentString);
|
2020-06-14 11:39:04 +00:00
|
|
|
var rows = doc.QuerySelectorAll("table.torrent_table > tbody > tr.torrent");
|
|
|
|
foreach (var row in rows)
|
2016-11-19 10:33:00 +00:00
|
|
|
{
|
2020-06-14 11:39:04 +00:00
|
|
|
var qDetailsLink = row.QuerySelector("a[href^=\"torrents.php?id=\"]");
|
|
|
|
var title = qDetailsLink.TextContent;
|
|
|
|
// if it's a season search, we filter results. the trailing space is to match regex
|
|
|
|
if (query.Season > 0 && !seasonRegEx.Match($"{title} ").Success)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
var description = qDetailsLink.NextSibling.TextContent.Trim();
|
|
|
|
title += " " + description;
|
2020-03-26 22:15:28 +00:00
|
|
|
var comments = new Uri(SiteLink + qDetailsLink.GetAttribute("href"));
|
2020-06-14 11:39:04 +00:00
|
|
|
var torrentId = qDetailsLink.GetAttribute("href").Split('=').Last();
|
|
|
|
var link = new Uri(SiteLink + "torrents.php?action=download&id=" + torrentId);
|
|
|
|
|
|
|
|
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.freeleech_normal") != null ? 0 : 1;
|
|
|
|
|
2020-04-07 16:17:17 +00:00
|
|
|
var category = new List<int> { TvCategoryParser.ParseTvShowQuality(description) };
|
2020-06-14 11:39:04 +00:00
|
|
|
|
2020-03-26 22:15:28 +00:00
|
|
|
var release = new ReleaseInfo
|
|
|
|
{
|
|
|
|
MinimumRatio = 1,
|
|
|
|
MinimumSeedTime = 0,
|
|
|
|
Description = description,
|
2020-06-14 11:39:04 +00:00
|
|
|
Title = title,
|
2020-03-26 22:15:28 +00:00
|
|
|
PublishDate = publishDate,
|
|
|
|
Category = category,
|
|
|
|
Link = link,
|
|
|
|
Comments = comments,
|
|
|
|
Guid = link,
|
|
|
|
Seeders = seeders,
|
|
|
|
Peers = leechers + seeders,
|
|
|
|
Size = size,
|
|
|
|
Grabs = grabs,
|
|
|
|
Files = files,
|
2020-06-14 11:39:04 +00:00
|
|
|
DownloadVolumeFactor = dlVolumeFactor,
|
2020-03-26 22:15:28 +00:00
|
|
|
UploadVolumeFactor = 1
|
|
|
|
};
|
2016-11-19 10:33:00 +00:00
|
|
|
releases.Add(release);
|
2017-04-15 08:45:10 +00:00
|
|
|
}
|
2016-11-19 10:33:00 +00:00
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
2020-06-09 17:36:57 +00:00
|
|
|
OnParseError(results.ContentString, ex);
|
2016-11-19 10:33:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return releases;
|
|
|
|
}
|
2020-06-14 11:39:04 +00:00
|
|
|
|
|
|
|
private string StripSearchString(string term)
|
|
|
|
{
|
|
|
|
// Search does not support searching with episode numbers so strip it if we have one
|
|
|
|
// Ww AND filter the result later to archive the proper result
|
|
|
|
term = Regex.Replace(term, @"[S|E]\d\d", string.Empty);
|
|
|
|
return term.Trim();
|
|
|
|
}
|
|
|
|
|
2016-11-19 10:33:00 +00:00
|
|
|
}
|
|
|
|
}
|