2017-10-29 06:50:47 +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;
|
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;
|
|
|
|
|
using AngleSharp.Parser.Html;
|
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
|
|
|
|
{
|
2017-07-10 20:58:44 +00:00
|
|
|
|
public class TVVault : BaseWebIndexer
|
2016-11-19 10:33:00 +00:00
|
|
|
|
{
|
2017-10-29 06:50:47 +00:00
|
|
|
|
private string LoginUrl { get { return SiteLink + "login.php"; } }
|
|
|
|
|
private string BrowseUrl { get { return SiteLink + "torrents.php"; } }
|
2016-11-19 10:33:00 +00:00
|
|
|
|
|
2017-10-29 06:50:47 +00:00
|
|
|
|
private new ConfigurationDataBasicLoginWithRSSAndDisplay configData
|
2016-11-19 10:33:00 +00:00
|
|
|
|
{
|
|
|
|
|
get { return (ConfigurationDataBasicLoginWithRSSAndDisplay)base.configData; }
|
|
|
|
|
set { base.configData = value; }
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-05 09:42:03 +00:00
|
|
|
|
public TVVault(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
|
2016-11-19 10:33:00 +00:00
|
|
|
|
: base(name: "TV-Vault",
|
|
|
|
|
description: "A TV tracker for old shows.",
|
|
|
|
|
link: "https://tv-vault.me/",
|
|
|
|
|
caps: TorznabUtil.CreateDefaultTorznabTVCaps(),
|
2017-07-10 20:58:44 +00:00
|
|
|
|
configService: configService,
|
2016-11-19 10:33:00 +00:00
|
|
|
|
client: wc,
|
|
|
|
|
logger: l,
|
|
|
|
|
p: ps,
|
|
|
|
|
configData: new ConfigurationDataBasicLoginWithRSSAndDisplay())
|
|
|
|
|
{
|
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);
|
2017-04-15 08:45:10 +00:00
|
|
|
|
await ConfigureIfOK(result.Cookies, result.Content != null && result.Content.Contains("logout.php"), () =>
|
|
|
|
|
{
|
|
|
|
|
var errorMessage = result.Content;
|
|
|
|
|
throw new ExceptionWithConfigData(errorMessage, configData);
|
2016-11-19 10:33:00 +00:00
|
|
|
|
});
|
|
|
|
|
return IndexerConfigurationStatus.RequiresTesting;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-15 08:45:10 +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
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
2017-04-15 08:45:10 +00:00
|
|
|
|
var searchString = query.GetQueryString();
|
|
|
|
|
var searchUrl = BrowseUrl;
|
|
|
|
|
|
|
|
|
|
var queryCollection = new NameValueCollection();
|
|
|
|
|
queryCollection.Add("searchstr", StripSearchString(searchString));
|
|
|
|
|
queryCollection.Add("order_by", "s3");
|
|
|
|
|
queryCollection.Add("order_way", "desc");
|
|
|
|
|
queryCollection.Add("disablegrouping", "1");
|
|
|
|
|
|
|
|
|
|
searchUrl += "?" + queryCollection.GetQueryString();
|
|
|
|
|
|
2016-11-19 10:33:00 +00:00
|
|
|
|
var results = await RequestStringWithCookies(searchUrl);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string RowsSelector = "table.torrent_table > tbody > tr.torrent";
|
|
|
|
|
|
2017-04-15 08:45:10 +00:00
|
|
|
|
var SearchResultParser = new HtmlParser();
|
2016-11-19 10:33:00 +00:00
|
|
|
|
var SearchResultDocument = SearchResultParser.Parse(results.Content);
|
2017-04-15 08:45:10 +00:00
|
|
|
|
var Rows = SearchResultDocument.QuerySelectorAll(RowsSelector);
|
|
|
|
|
foreach (var Row in Rows)
|
2016-11-19 10:33:00 +00:00
|
|
|
|
{
|
|
|
|
|
var release = new ReleaseInfo();
|
|
|
|
|
|
2017-04-15 08:45:10 +00:00
|
|
|
|
release.MinimumRatio = 1;
|
|
|
|
|
release.MinimumSeedTime = 0;
|
|
|
|
|
|
|
|
|
|
var qDetailsLink = Row.QuerySelector("a[href^=\"torrents.php?id=\"]");
|
|
|
|
|
var DescStr = qDetailsLink.NextSibling;
|
|
|
|
|
var Files = Row.QuerySelector("td:nth-child(3)");
|
|
|
|
|
var Added = Row.QuerySelector("td:nth-child(4)");
|
|
|
|
|
var Size = Row.QuerySelector("td:nth-child(5)").FirstChild;
|
|
|
|
|
var Grabs = Row.QuerySelector("td:nth-child(6)");
|
|
|
|
|
var Seeders = Row.QuerySelector("td:nth-child(7)");
|
|
|
|
|
var Leechers = Row.QuerySelector("td:nth-child(8)");
|
|
|
|
|
var FreeLeech = Row.QuerySelector("strong.freeleech_normal");
|
|
|
|
|
|
|
|
|
|
var TorrentIdParts = qDetailsLink.GetAttribute("href").Split('=');
|
|
|
|
|
var TorrentId = TorrentIdParts[TorrentIdParts.Length - 1];
|
|
|
|
|
var DLLink = "torrents.php?action=download&id=" + TorrentId.ToString();
|
|
|
|
|
|
|
|
|
|
release.Description = DescStr.TextContent.Trim();
|
|
|
|
|
release.Title = qDetailsLink.TextContent + " " + release.Description;
|
|
|
|
|
release.PublishDate = DateTimeUtil.FromTimeAgo(Added.TextContent);
|
|
|
|
|
release.Category = new List<int> { TvCategoryParser.ParseTvShowQuality(release.Description) };
|
|
|
|
|
|
|
|
|
|
release.Link = new Uri(SiteLink + DLLink);
|
|
|
|
|
release.Comments = new Uri(SiteLink + qDetailsLink.GetAttribute("href"));
|
|
|
|
|
release.Guid = release.Link;
|
|
|
|
|
|
|
|
|
|
release.Seeders = ParseUtil.CoerceInt(Seeders.TextContent);
|
|
|
|
|
release.Peers = ParseUtil.CoerceInt(Leechers.TextContent) + release.Seeders;
|
|
|
|
|
release.Size = ReleaseInfo.GetBytes(Size.TextContent);
|
|
|
|
|
release.Grabs = ReleaseInfo.GetBytes(Grabs.TextContent);
|
|
|
|
|
release.Files = ReleaseInfo.GetBytes(Files.TextContent);
|
|
|
|
|
|
|
|
|
|
if (FreeLeech != null)
|
|
|
|
|
release.DownloadVolumeFactor = 0;
|
2016-11-19 10:33:00 +00:00
|
|
|
|
else
|
2017-04-15 08:45:10 +00:00
|
|
|
|
release.DownloadVolumeFactor = 1;
|
|
|
|
|
|
2016-11-19 10:33:00 +00:00
|
|
|
|
release.UploadVolumeFactor = 1;
|
|
|
|
|
|
|
|
|
|
releases.Add(release);
|
2017-04-15 08:45:10 +00:00
|
|
|
|
}
|
2016-11-19 10:33:00 +00:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
OnParseError(results.Content, ex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return releases;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|