This commit is contained in:
kaso17
2019-01-10 16:00:16 +01:00
7 changed files with 165 additions and 144 deletions

View File

@@ -46,7 +46,7 @@ namespace Jackett.Common.Indexers
configData.LoadValuesFromJson(configJson);
var releases = await PerformQuery(new TorznabQuery());
await ConfigureIfOK(string.Empty, releases.Count() > 0, () =>
await ConfigureIfOK(string.Empty, releases.Any(), () =>
{
throw new Exception("Could not find releases from this URL");
});
@@ -56,10 +56,57 @@ namespace Jackett.Common.Indexers
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
return await PerformQuery(query, 0);
var ResultParser = new HtmlParser();
var releases = new List<ReleaseInfo>();
var searchString = query.GetQueryString();
var queryCollection = new NameValueCollection();
if (string.IsNullOrWhiteSpace(searchString))
{
return await PerformLatestQuery(query);
}
else
{
queryCollection.Add("method", "search");
searchString = searchString.Replace("'", ""); // ignore ' (e.g. search for america's Next Top Model)
queryCollection.Add("value", searchString);
}
var searchUrl = ApiEndpoint + "?" + queryCollection.GetQueryString();
var response = await RequestStringWithCookiesAndRetry(searchUrl, string.Empty);
try
{
if (response.Content.Contains("Nothing was found"))
{
return releases.ToArray();
}
var dom = ResultParser.Parse(response.Content);
var resultLinks = dom.QuerySelectorAll("ul > li > a");
var uniqueShowLinks = new HashSet<string>();
foreach (var resultLink in resultLinks)
{
var href = SiteLink + resultLink.Attributes["href"].Value.Substring(1); // = https://horriblesubs.info/shows/boruto-naruto-next-generations#71
var showUrl = href.Substring(0, href.LastIndexOf("#"));
uniqueShowLinks.Add(showUrl);
}
foreach (var showLink in uniqueShowLinks)
{
var showReleases = await GetReleases(showLink, latestOnly: false);
releases.AddRange(showReleases);
}
}
catch (Exception ex)
{
OnParseError(response.Content, ex);
}
return releases;
}
private async Task<IEnumerable<ReleaseInfo>> PerformLatestQuery(TorznabQuery query, int attempts)
private async Task<IEnumerable<ReleaseInfo>> PerformLatestQuery(TorznabQuery query)
{
var ResultParser = new HtmlParser();
var releases = new List<ReleaseInfo>();
@@ -80,13 +127,14 @@ namespace Jackett.Common.Indexers
var dom = ResultParser.Parse(response.Content);
var latestresults = dom.QuerySelectorAll("ul > li > a");
foreach (var row in latestresults)
foreach (var resultLink in latestresults)
{
var href = SiteLink + row.Attributes["href"].Value.Substring(1);
var showrels = await GetRelease(href);
releases.AddRange(showrels);
var href = SiteLink + resultLink.Attributes["href"].Value.Substring(1); // = https://horriblesubs.info/shows/boruto-naruto-next-generations#71
var episodeNumber = href.Substring(href.LastIndexOf("#") + 1); // = 71
var showUrl = href.Substring(0, href.LastIndexOf("#"));
var showReleases = await GetReleases(showUrl, latestOnly: true, titleContains: episodeNumber);
releases.AddRange(showReleases);
}
}
catch (Exception ex)
{
@@ -96,15 +144,12 @@ namespace Jackett.Common.Indexers
return releases;
}
private async Task<IEnumerable<ReleaseInfo>> GetRelease(string ResultURL)
private async Task<IEnumerable<ReleaseInfo>> GetReleases(string ResultURL, bool latestOnly, string titleContains = null)
{
var releases = new List<ReleaseInfo>();
var ResultParser = new HtmlParser();
try
{
var episodeno = ResultURL.Substring(ResultURL.LastIndexOf("#") + 1); // = 71
ResultURL = ResultURL.Replace("#" + episodeno, ""); // = https://horriblesubs.info/shows/boruto-naruto-next-generations
var showPageResponse = await RequestStringWithCookiesAndRetry(ResultURL, string.Empty);
await FollowIfRedirect(showPageResponse);
@@ -116,12 +161,28 @@ namespace Jackett.Common.Indexers
int ShowID = int.Parse(match.Groups[2].Value);
string showAPIURL = ApiEndpoint + "?method=getshows&type=show&showid=" + ShowID; //https://horriblesubs.info/api.php?method=getshows&type=show&showid=869
var showAPIResponse = await RequestStringWithCookiesAndRetry(showAPIURL, string.Empty);
var apiUrls = new string[] {
ApiEndpoint + "?method=getshows&type=batch&showid=" + ShowID, //https://horriblesubs.info/api.php?method=getshows&type=batch&showid=1194
ApiEndpoint + "?method=getshows&type=show&showid=" + ShowID //https://horriblesubs.info/api.php?method=getshows&type=show&showid=869
};
var releaserows = new List<AngleSharp.Dom.IElement>();
foreach (string apiUrl in apiUrls)
{
int nextId = 0;
while(true)
{
var showAPIResponse = await RequestStringWithCookiesAndRetry(apiUrl + "&nextid=" + nextId, string.Empty);
var showAPIdom = ResultParser.Parse(showAPIResponse.Content);
var releaseRowResults = showAPIdom.QuerySelectorAll("div.rls-info-container");
releaserows.AddRange(releaseRowResults);
nextId++;
var showAPIdom = ResultParser.Parse(showAPIResponse.Content);
var releaserows = showAPIdom.QuerySelectorAll("div.rls-info-container");
if (releaseRowResults.Length == 0 || latestOnly) {
break;
}
}
}
foreach (var releaserow in releaserows)
{
@@ -130,14 +191,14 @@ namespace Jackett.Common.Indexers
title = title.Replace("SD720p1080p", "");
title = title.Replace(dateStr, "");
if (title.Contains(episodeno) == false)
if (!string.IsNullOrWhiteSpace(titleContains) && !title.Contains(titleContains))
{
continue;
}
// Ensure fansub group name is present in the title
// This is needed for things like configuring tag restrictions in Sonarr
if (title.Contains("[HorribleSubs]") == false)
if (!title.Contains("[HorribleSubs]"))
{
title = "[HorribleSubs] " + title;
}
@@ -175,6 +236,7 @@ namespace Jackett.Common.Indexers
if (p480.QuerySelector(".hs-torrent-link > a") != null)
{
release.Link = new Uri(p480.QuerySelector(".hs-torrent-link > a").GetAttribute("href"));
release.Comments = new Uri(release.Link.AbsoluteUri.Replace("/torrent", string.Empty));
release.Guid = release.Link;
}
if (p480.QuerySelector(".hs-magnet-link > a") != null)
@@ -204,6 +266,7 @@ namespace Jackett.Common.Indexers
if (p720.QuerySelector(".hs-torrent-link > a") != null)
{
release.Link = new Uri(p720.QuerySelector(".hs-torrent-link > a").GetAttribute("href"));
release.Comments = new Uri(release.Link.AbsoluteUri.Replace("/torrent", string.Empty));
release.Guid = release.Link;
}
if (p720.QuerySelector(".hs-magnet-link > a") != null)
@@ -233,6 +296,7 @@ namespace Jackett.Common.Indexers
if (p1080.QuerySelector(".hs-torrent-link > a") != null)
{
release.Link = new Uri(p1080.QuerySelector(".hs-torrent-link > a").GetAttribute("href"));
release.Comments = new Uri(release.Link.AbsoluteUri.Replace("/torrent", string.Empty));
release.Guid = release.Link;
}
if (p1080.QuerySelector(".hs-magnet-link > a") != null)
@@ -250,55 +314,5 @@ namespace Jackett.Common.Indexers
}
return releases;
}
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query, int attempts)
{
var ResultParser = new HtmlParser();
var releases = new List<ReleaseInfo>();
var searchString = query.GetQueryString();
var queryCollection = new NameValueCollection();
if (string.IsNullOrWhiteSpace(searchString))
{
return await PerformLatestQuery(query, attempts);
}
else
{
queryCollection.Add("method", "search");
searchString = searchString.Replace("'", ""); // ignore ' (e.g. search for america's Next Top Model)
queryCollection.Add("value", searchString);
}
var searchUrl = ApiEndpoint + "?" + queryCollection.GetQueryString();
var response = await RequestStringWithCookiesAndRetry(searchUrl, string.Empty);
try
{
if (response.Content.Contains("Nothing was found"))
{
return releases.ToArray();
}
var dom = ResultParser.Parse(response.Content);
var showlinks = dom.QuerySelectorAll("ul > li > a");
foreach (var showlink in showlinks)
{
var href = SiteLink + showlink.Attributes["href"].Value.Substring(1); // = https://horriblesubs.info/shows/boruto-naruto-next-generations#71
var showrels = await GetRelease(href);
releases.AddRange(showrels);
}
}
catch (Exception ex)
{
OnParseError(response.Content, ex);
}
return releases;
}
}
}

View File

@@ -543,8 +543,15 @@ namespace Jackett.Common.Indexers
var pubDateText = span[1].TextContent.Trim();
var sizeText = span[2].TextContent.Trim();
long size = ReleaseInfo.GetBytes(sizeText);
DateTime publishDate = DateTime.ParseExact(pubDateText, "dd-MM-yyyy", null);
long size = 0;
try
{
size = ReleaseInfo.GetBytes(sizeText);
} catch
{
}
DateTime publishDate;
DateTime.TryParseExact(pubDateText, "dd-MM-yyyy", null, DateTimeStyles.None, out publishDate);
var div = row.QuerySelector("div");
@@ -654,7 +661,8 @@ namespace Jackett.Common.Indexers
result.Category = new List<int> { TorznabCatType.Movies.ID };
}
result.Size = size;
if (size > 0)
result.Size = size;
result.Link = new Uri(detailsUrl);
result.Guid = result.Link;
result.PublishDate = publishDate;

View File

@@ -58,63 +58,73 @@ namespace Jackett.Common.Indexers
TorznabCaps.Categories.Clear();
// Movies
AddCategoryMapping(6, TorznabCatType.MoviesSD, "XVID");
AddCategoryMapping(7, TorznabCatType.MoviesSD, "X264");
AddCategoryMapping(95, TorznabCatType.MoviesSD, "WEBRIP");
AddCategoryMapping(5, TorznabCatType.MoviesHD, "HD 720P");
AddCategoryMapping(4, TorznabCatType.MoviesHD, "HD 1080P X264");
AddCategoryMapping(100, TorznabCatType.MoviesHD, "HD 1080P X265");
AddCategoryMapping(94, TorznabCatType.MoviesHD, "WEBDL");
AddCategoryMapping(107, TorznabCatType.MoviesHD, "4K");
AddCategoryMapping(1, TorznabCatType.MoviesBluRay, "FULL BLURAY");
AddCategoryMapping(2, TorznabCatType.MoviesBluRay, "BLURAY REMUX");
AddCategoryMapping(3, TorznabCatType.MoviesBluRay, "FULL BLURAY 3D");
AddCategoryMapping(8, TorznabCatType.MoviesDVD, "FULL DVD");
AddCategoryMapping(9, TorznabCatType.MoviesOther, "VOSTFR");
AddCategoryMapping(36, TorznabCatType.XXX, "XXX");
AddCategoryMapping(118, TorznabCatType.MoviesBluRay, "UHD FULL BLURAY");
AddCategoryMapping(119, TorznabCatType.MoviesBluRay, "UHD BLURAY REMUX");
AddCategoryMapping(107, TorznabCatType.MoviesUHD, "UHD 2160P X265");
AddCategoryMapping(1, TorznabCatType.MoviesBluRay, "FULL BLURAY");
AddCategoryMapping(2, TorznabCatType.MoviesBluRay, "BLURAY REMUX");
AddCategoryMapping(100, TorznabCatType.MoviesHD, "HD 1080P X265");
AddCategoryMapping(4, TorznabCatType.MoviesHD, "HD 1080P X264");
AddCategoryMapping(5, TorznabCatType.MoviesHD, "HD 720P X264");
AddCategoryMapping(7, TorznabCatType.MoviesSD, "SD X264");
AddCategoryMapping(8, TorznabCatType.MoviesDVD, "FULL DVD");
AddCategoryMapping(3, TorznabCatType.Movies3D, "3D");
AddCategoryMapping(6, TorznabCatType.MoviesSD, "XVID");
AddCategoryMapping(122, TorznabCatType.MoviesHD, "HDTV");
AddCategoryMapping(94, TorznabCatType.MoviesWEBDL, "WEBDL");
AddCategoryMapping(95, TorznabCatType.MoviesWEBDL, "WEBRIP");
AddCategoryMapping(12, TorznabCatType.TVDocumentary, "DOCS");
AddCategoryMapping(33, TorznabCatType.MoviesOther, "SPECTACLE");
AddCategoryMapping(31, TorznabCatType.MoviesOther, "ANIMATION");
AddCategoryMapping(9, TorznabCatType.MoviesOther, "VOSTFR");
// Series
AddCategoryMapping(14, TorznabCatType.TVSD, "SD VF");
AddCategoryMapping(16, TorznabCatType.TVSD, "SD VF VOSTFR");
AddCategoryMapping(15, TorznabCatType.TVHD, "HD VF");
AddCategoryMapping(17, TorznabCatType.TVHD, "HD VF VOSTFR");
AddCategoryMapping(13, TorznabCatType.TVOTHER, "PACK");
AddCategoryMapping(98, TorznabCatType.TVOTHER, "PACK VOSTFR HD");
AddCategoryMapping(16, TorznabCatType.TVOTHER, "PACK VOSTFR SD");
AddCategoryMapping(30, TorznabCatType.TVOTHER, "EMISSIONS");
AddCategoryMapping(34, TorznabCatType.TVOTHER, "EMISSIONS");
AddCategoryMapping(33, TorznabCatType.TVOTHER, "SHOWS");
// Anime
AddCategoryMapping(31, TorznabCatType.TVAnime, "MOVIES ANIME");
AddCategoryMapping(32, TorznabCatType.TVAnime, "SERIES ANIME");
AddCategoryMapping(110, TorznabCatType.TVAnime, "ANIME VOSTFR");
AddCategoryMapping(101, TorznabCatType.TVAnime, "PACK ANIME");
// Documentaries
AddCategoryMapping(12, TorznabCatType.TVDocumentary, "DOCS");
AddCategoryMapping(104, TorznabCatType.TVOTHER, "BLURAY");
AddCategoryMapping(13, TorznabCatType.TVOTHER, "PACK VF");
AddCategoryMapping(15, TorznabCatType.TVHD, "HD VF");
AddCategoryMapping(14, TorznabCatType.TVSD, "SD VF");
AddCategoryMapping(98, TorznabCatType.TVOTHER, "PACK VOSTFR");
AddCategoryMapping(17, TorznabCatType.TVHD, "HD VF VOSTFR");
AddCategoryMapping(16, TorznabCatType.TVSD, "SD VF VOSTFR");
AddCategoryMapping(101, TorznabCatType.TVAnime, "PACK ANIME");
AddCategoryMapping(32, TorznabCatType.TVAnime, "ANIME VF");
AddCategoryMapping(110, TorznabCatType.TVAnime, "ANIME VOSTFR");
AddCategoryMapping(123, TorznabCatType.TVOTHER, "ANIMATION");
AddCategoryMapping(109, TorznabCatType.TVDocumentary, "DOCS");
AddCategoryMapping(30, TorznabCatType.TVOTHER, "EMISSIONS");
AddCategoryMapping(34, TorznabCatType.TVOTHER, "SPORT");
// Music
AddCategoryMapping(20, TorznabCatType.AudioVideo, "CONCERT");
AddCategoryMapping(20, TorznabCatType.AudioVideo, "CONCERT");
// Books
AddCategoryMapping(24, TorznabCatType.BooksEbook, "ENOOKS NOVEL");
AddCategoryMapping(96, TorznabCatType.BooksMagazines, "EBOOKS MAGAZINES");
AddCategoryMapping(116, TorznabCatType.BooksEbook, "EBOOKS NOVEL JUNIOR");
AddCategoryMapping(99, TorznabCatType.BooksOther, "EBOOKS BD");
AddCategoryMapping(102, TorznabCatType.BooksComics, "EBOOKS COMICS");
AddCategoryMapping(103, TorznabCatType.BooksOther, "EBOOKS MANGA");
// Other
AddCategoryMapping(21, TorznabCatType.PC, "PC");
AddCategoryMapping(22, TorznabCatType.PCMac, "PC");
AddCategoryMapping(25, TorznabCatType.PCGames, "GAMES");
AddCategoryMapping(26, TorznabCatType.ConsoleXbox360, "GAMES");
AddCategoryMapping(28, TorznabCatType.ConsoleWii, "GAMES");
AddCategoryMapping(27, TorznabCatType.ConsolePS3, "GAMES");
AddCategoryMapping(29, TorznabCatType.ConsoleNDS, "GAMES");
AddCategoryMapping(24, TorznabCatType.BooksEbook, "EBOOKS");
AddCategoryMapping(96, TorznabCatType.BooksEbook, "EBOOKS MAGAZINES");
AddCategoryMapping(99, TorznabCatType.BooksEbook, "EBOOKS ANIME");
AddCategoryMapping(23, TorznabCatType.PCPhoneAndroid, "ANDROID");
// SOFTWARE
AddCategoryMapping(25, TorznabCatType.PCGames, "PC GAMES");
AddCategoryMapping(27, TorznabCatType.ConsolePS3, "PS GAMES");
AddCategoryMapping(111, TorznabCatType.PCMac, "MAC GAMES");
AddCategoryMapping(112, TorznabCatType.PC, "LINUX GAMES");
AddCategoryMapping(26, TorznabCatType.ConsoleXbox360, "XBOX GAMES");
AddCategoryMapping(28, TorznabCatType.ConsoleWii, "WII GAMES");
AddCategoryMapping(29, TorznabCatType.ConsoleNDS, "NDS GAMES");
AddCategoryMapping(117, TorznabCatType.PC, "ROM");
AddCategoryMapping(21, TorznabCatType.PC, "PC SOFTWARE");
AddCategoryMapping(22, TorznabCatType.PCMac, "MAC SOFTWARE");
AddCategoryMapping(23, TorznabCatType.PCPhoneAndroid, "ANDROID");
AddCategoryMapping(36, TorznabCatType.XXX, "XxX / Films");
AddCategoryMapping(105, TorznabCatType.XXX, "XxX / Séries");
AddCategoryMapping(114, TorznabCatType.XXX, "XxX / Lesbiennes ");
AddCategoryMapping(115, TorznabCatType.XXX, "XxX / Gays");
AddCategoryMapping(113, TorznabCatType.XXX, "XxX / Hentai");
// XxX
AddCategoryMapping(36, TorznabCatType.XXX, "XxX / Films");
AddCategoryMapping(105, TorznabCatType.XXX, "XxX / Séries");
AddCategoryMapping(114, TorznabCatType.XXX, "XxX / Lesbiennes");
AddCategoryMapping(115, TorznabCatType.XXX, "XxX / Gays");
AddCategoryMapping(113, TorznabCatType.XXX, "XxX / Hentai");
AddCategoryMapping(120, TorznabCatType.XXX, "XxX / Magazines");
}
/// <summary>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<Version>0.0.0</Version>
<NoWarn>NU1605</NoWarn>
</PropertyGroup>
@@ -12,29 +12,18 @@
<PackageReference Include="AutoMapper" Version="8.0.0" />
<PackageReference Include="BencodeNET" Version="2.2.24" />
<PackageReference Include="CloudFlareUtilities" Version="1.2.0" />
<PackageReference Include="CommandLineParser" Version="2.3.0" />
<PackageReference Include="CommandLineParser" Version="2.4.3" />
<PackageReference Include="CsQuery.NETStandard" Version="1.3.6.1" />
<PackageReference Include="DotNet4.SocksProxy" Version="1.4.0.1" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.2.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Include="MimeMapping" Version="1.0.1.12" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="NLog" Version="4.5.11" />
<PackageReference Include="SharpZipLib" Version="1.1.0" />
<PackageReference Include="YamlDotNet" Version="5.3.0" />
</ItemGroup>
<!-- Conditionally obtain references for the .NET Full framework target -->
<ItemGroup Condition="'$(TargetFramework)' != 'netstandard2.0'">
<PackageReference Include="CsQuery" Version="1.3.5-beta5" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="1.1.2" />
<Reference Include="System.ServiceProcess" />
</ItemGroup>
<!-- Conditionally obtain references for the .NETStandard target -->
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="CsQuery.NETStandard" Version="1.3.6.1" />
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="4.5.0" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.2.0" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="4.5.0" />
<PackageReference Include="YamlDotNet" Version="5.3.0" />
</ItemGroup>
<ItemGroup>

View File

@@ -25,7 +25,7 @@
<PackageReference Include="Autofac" Version="4.8.1" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.3.1" />
<PackageReference Include="AutoMapper" Version="8.0.0" />
<PackageReference Include="CommandLineParser" Version="2.3.0" />
<PackageReference Include="CommandLineParser" Version="2.4.3" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.2.0" />
@@ -35,9 +35,9 @@
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
<PackageReference Include="NLog" Version="4.5.11" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.7.0" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.7.1" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="4.5.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" />
</ItemGroup>
<ItemGroup>

View File

@@ -110,7 +110,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommandLineParser">
<Version>2.3.0</Version>
<Version>2.4.3</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net461;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>net461;netcoreapp2.2</TargetFrameworks>
<ApplicationIcon>jackett.ico</ApplicationIcon>
<AssemblyName>JackettUpdater</AssemblyName>
<OutputType>Exe</OutputType>