mirror of https://github.com/Jackett/Jackett
* Add IMDB search * Improve TV season search
This commit is contained in:
parent
2c4ca6be1f
commit
a7d6cafbc6
|
@ -2,6 +2,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -22,23 +23,23 @@ namespace Jackett.Common.Indexers
|
||||||
private string LoginUrl => SiteLink + "login.php";
|
private string LoginUrl => SiteLink + "login.php";
|
||||||
private string BrowseUrl => SiteLink + "torrents.php";
|
private string BrowseUrl => SiteLink + "torrents.php";
|
||||||
|
|
||||||
private new ConfigurationDataBasicLoginWithRSSAndDisplay configData
|
private new ConfigurationDataBasicLogin configData => (ConfigurationDataBasicLogin)base.configData;
|
||||||
{
|
|
||||||
get => (ConfigurationDataBasicLoginWithRSSAndDisplay)base.configData;
|
|
||||||
set => base.configData = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TVVault(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
|
public TVVault(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
|
||||||
: base(id: "tvvault",
|
: base(id: "tvvault",
|
||||||
name: "TV-Vault",
|
name: "TV-Vault",
|
||||||
description: "A TV tracker for old shows.",
|
description: "A TV tracker for old shows",
|
||||||
link: "https://tv-vault.me/",
|
link: "https://tv-vault.me/",
|
||||||
caps: TorznabUtil.CreateDefaultTorznabTVCaps(),
|
caps: new TorznabCapabilities
|
||||||
|
{
|
||||||
|
SupportsImdbMovieSearch = true
|
||||||
|
// SupportsImdbTVSearch = true (supported by the site but disabled due to #8107)
|
||||||
|
},
|
||||||
configService: configService,
|
configService: configService,
|
||||||
client: wc,
|
client: wc,
|
||||||
logger: l,
|
logger: l,
|
||||||
p: ps,
|
p: ps,
|
||||||
configData: new ConfigurationDataBasicLoginWithRSSAndDisplay())
|
configData: new ConfigurationDataBasicLogin())
|
||||||
{
|
{
|
||||||
Encoding = Encoding.UTF8;
|
Encoding = Encoding.UTF8;
|
||||||
Language = "en-us";
|
Language = "en-us";
|
||||||
|
@ -66,70 +67,65 @@ namespace Jackett.Common.Indexers
|
||||||
return IndexerConfigurationStatus.RequiresTesting;
|
return IndexerConfigurationStatus.RequiresTesting;
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
||||||
{
|
{
|
||||||
var releases = new List<ReleaseInfo>();
|
var releases = new List<ReleaseInfo>();
|
||||||
|
|
||||||
var searchString = query.GetQueryString();
|
var qc = new NameValueCollection
|
||||||
var searchUrl = BrowseUrl;
|
|
||||||
|
|
||||||
var queryCollection = new NameValueCollection
|
|
||||||
{
|
{
|
||||||
{ "searchstr", StripSearchString(searchString) },
|
|
||||||
{ "order_by", "s3" },
|
{ "order_by", "s3" },
|
||||||
{ "order_way", "desc" },
|
{ "order_way", "desc" },
|
||||||
{ "disablegrouping", "1" }
|
{ "disablegrouping", "1" }
|
||||||
};
|
};
|
||||||
|
|
||||||
searchUrl += "?" + queryCollection.GetQueryString();
|
if (query.IsImdbQuery)
|
||||||
|
{
|
||||||
|
qc.Add("action", "advanced");
|
||||||
|
qc.Add("imdbid", query.ImdbID);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
qc.Add("searchstr", StripSearchString(query.GetQueryString()));
|
||||||
|
|
||||||
|
var searchUrl = BrowseUrl + "?" + qc.GetQueryString();
|
||||||
var results = await RequestStringWithCookies(searchUrl);
|
var results = await RequestStringWithCookies(searchUrl);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var RowsSelector = "table.torrent_table > tbody > tr.torrent";
|
var seasonRegEx = new Regex(@$"Season\s+0*{query.Season}[^\d]", RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
var SearchResultParser = new HtmlParser();
|
var parser = new HtmlParser();
|
||||||
var SearchResultDocument = SearchResultParser.ParseDocument(results.Content);
|
var doc = parser.ParseDocument(results.Content);
|
||||||
var Rows = SearchResultDocument.QuerySelectorAll(RowsSelector);
|
var rows = doc.QuerySelectorAll("table.torrent_table > tbody > tr.torrent");
|
||||||
foreach (var Row in Rows)
|
foreach (var row in rows)
|
||||||
{
|
{
|
||||||
var qDetailsLink = Row.QuerySelector("a[href^=\"torrents.php?id=\"]");
|
var qDetailsLink = row.QuerySelector("a[href^=\"torrents.php?id=\"]");
|
||||||
var DescStr = qDetailsLink.NextSibling;
|
var title = qDetailsLink.TextContent;
|
||||||
var Files = Row.QuerySelector("td:nth-child(3)");
|
// if it's a season search, we filter results. the trailing space is to match regex
|
||||||
var Added = Row.QuerySelector("td:nth-child(4)");
|
if (query.Season > 0 && !seasonRegEx.Match($"{title} ").Success)
|
||||||
var Size = Row.QuerySelector("td:nth-child(5)").FirstChild;
|
continue;
|
||||||
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 description = qDetailsLink.NextSibling.TextContent.Trim();
|
||||||
var TorrentId = TorrentIdParts[TorrentIdParts.Length - 1];
|
title += " " + description;
|
||||||
var DLLink = "torrents.php?action=download&id=" + TorrentId.ToString();
|
|
||||||
var link = new Uri(SiteLink + DLLink);
|
|
||||||
var seeders = ParseUtil.CoerceInt(Seeders.TextContent);
|
|
||||||
var description = DescStr.TextContent.Trim();
|
|
||||||
var publishDate = DateTimeUtil.FromTimeAgo(Added.TextContent);
|
|
||||||
var comments = new Uri(SiteLink + qDetailsLink.GetAttribute("href"));
|
var comments = new Uri(SiteLink + qDetailsLink.GetAttribute("href"));
|
||||||
var leechers = ParseUtil.CoerceInt(Leechers.TextContent);
|
var torrentId = qDetailsLink.GetAttribute("href").Split('=').Last();
|
||||||
var size = ReleaseInfo.GetBytes(Size.TextContent);
|
var link = new Uri(SiteLink + "torrents.php?action=download&id=" + torrentId);
|
||||||
var grabs = ParseUtil.CoerceLong(Grabs.TextContent);
|
|
||||||
var files = ParseUtil.CoerceLong(Files.TextContent);
|
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;
|
||||||
|
|
||||||
var category = new List<int> { TvCategoryParser.ParseTvShowQuality(description) };
|
var category = new List<int> { TvCategoryParser.ParseTvShowQuality(description) };
|
||||||
|
|
||||||
var release = new ReleaseInfo
|
var release = new ReleaseInfo
|
||||||
{
|
{
|
||||||
MinimumRatio = 1,
|
MinimumRatio = 1,
|
||||||
MinimumSeedTime = 0,
|
MinimumSeedTime = 0,
|
||||||
Description = description,
|
Description = description,
|
||||||
Title = qDetailsLink.TextContent + " " + description,
|
Title = title,
|
||||||
PublishDate = publishDate,
|
PublishDate = publishDate,
|
||||||
Category = category,
|
Category = category,
|
||||||
Link = link,
|
Link = link,
|
||||||
|
@ -140,7 +136,7 @@ namespace Jackett.Common.Indexers
|
||||||
Size = size,
|
Size = size,
|
||||||
Grabs = grabs,
|
Grabs = grabs,
|
||||||
Files = files,
|
Files = files,
|
||||||
DownloadVolumeFactor = FreeLeech != null ? 0 : 1,
|
DownloadVolumeFactor = dlVolumeFactor,
|
||||||
UploadVolumeFactor = 1
|
UploadVolumeFactor = 1
|
||||||
};
|
};
|
||||||
releases.Add(release);
|
releases.Add(release);
|
||||||
|
@ -153,5 +149,14 @@ namespace Jackett.Common.Indexers
|
||||||
|
|
||||||
return releases;
|
return releases;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue