BJ-Share, B2S-Share and Speed-Share: fix Anime search (#2171)

* Fixed anime search on BJShare, removing the season from search and changing the output from "Anime SXXEXX" to "Anime EXX".
Season had to be removed because the season numbering on anime is all wrong in this tracker.

* - Changed to change title based on search for category of every row in bj-share, instead of category of search
- Fixed title parse on B2S-Share and Speed-Share to animes (series not changed) from "Anime SXXEXX" to "Anime EXX"

* - Added anime title change on empty search as well - BJ-Share
This commit is contained in:
DarkSupremo 2017-11-20 12:27:25 -02:00 committed by kaso17
parent e163e6f8cf
commit d9178dd053
4 changed files with 55 additions and 18 deletions

View File

@ -227,8 +227,19 @@
details:
selector: a[href^="torrents-details.php?id="]
attribute: href
title:
is_anime:
optional: true
selector: a[href^="torrents.php?cat=11"]
attribute: href
title_anime:
selector: a[href^="torrents-details.php?id="]
filters:
- name: re_replace
args: ["(Ep[\\.]?[ ]?)|([S]\\d\\d[Ee])", "E"]
title_normal:
selector: a[href^="torrents-details.php?id="]
title:
text: "{{if .Result.is_anime }}{{ .Result.title_anime }}{{else}}{{ .Result.title_normal }}{{end}}"
download:
selector: a[href^="torrents-details.php?id="]
attribute: href

View File

@ -207,9 +207,30 @@
details:
selector: a[href^="torrents-details.php?id="]
attribute: href
title:
is_anime:
optional: true
selector: >
a[href^="torrents.php?cat=240"]
,a[href^="torrents.php?cat=189"]
,a[href^="torrents.php?cat=102"]
,a[href^="torrents.php?cat=103"]
,a[href^="torrents.php?cat=250"]
,a[href^="torrents.php?cat=144"]
,a[href^="torrents.php?cat=251"]
,a[href^="torrents.php?cat=227"]
,a[href^="torrents.php?cat=228"]
,a[href^="torrents.php?cat=191"]
attribute: href
title_anime:
selector: a[href^="torrents-details.php?id="]
filters:
- name: re_replace
args: ["(Ep[\\.]?[ ]?)|([S]\\d\\d[Ee])", "E"]
title_normal:
selector: a[href^="torrents-details.php?id="]
title:
text: "{{if .Result.is_anime }}{{ .Result.title_anime }}{{else}}{{ .Result.title_normal }}{{end}}"
filters:
- name: re_replace
args: ["^(\\[XXX]\\s)", ""]
- name: replace

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
@ -22,6 +23,7 @@ namespace Jackett.Indexers
private string LoginUrl { get { return SiteLink + "login.php"; } }
private string BrowseUrl { get { return SiteLink + "torrents.php"; } }
private string TodayUrl { get { return SiteLink + "torrents.php?action=today"; } }
private char[] digits = new[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
private new ConfigurationDataBasicLoginWithRSSAndDisplay configData
{
@ -88,12 +90,11 @@ Encoding = Encoding.UTF8;
return IndexerConfigurationStatus.RequiresTesting;
}
private string StripSearchString(string term)
private string StripSearchString(string term, bool isAnime)
{
// 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();
return isAnime ? term.TrimEnd(digits) : Regex.Replace(term, @"[S|E]\d\d", string.Empty).Trim();
}
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
@ -160,6 +161,11 @@ Encoding = Encoding.UTF8;
}
var catStr = qCatLink.GetAttribute("href").Split('=')[1];
// if result is an anime, convert title from SXXEXX to EXX
if (catStr == "14")
{
release.Title = Regex.Replace(release.Title, @"(Ep[\.]?[ ]?)|([S]\d\d[Ee])", "E");
}
release.Category = MapTrackerCatToNewznab(catStr);
release.Link = new Uri(SiteLink + qDLLink.GetAttribute("href"));
@ -192,9 +198,10 @@ Encoding = Encoding.UTF8;
else // use search
{
var searchUrl = BrowseUrl;
var isSearchAnime = query.Categories.Any(s => s == TorznabCatType.TVAnime.ID);
var queryCollection = new NameValueCollection();
queryCollection.Add("searchstr", StripSearchString(searchString));
queryCollection.Add("searchstr", StripSearchString(searchString, isSearchAnime));
queryCollection.Add("order_by", "time");
queryCollection.Add("order_way", "desc");
queryCollection.Add("group_results", "1");
@ -237,6 +244,12 @@ Encoding = Encoding.UTF8;
var qCatLink = Row.QuerySelector("a[href^=\"/torrents.php?filter_cat\"]");
string CategoryStr = qCatLink.GetAttribute("href").Split('=')[1].Split('&')[0];
Category = MapTrackerCatToNewznab(CategoryStr);
// if result is an anime, convert title from SXXEXX to EXX
if (CategoryStr == "14")
{
Title = Regex.Replace(Title, @"(Ep[\.]?[ ]?)|([S]\d\d[Ee])", "E");
}
YearStr = qDetailsLink.NextSibling.TextContent.Trim().TrimStart('[').TrimEnd(']');
YearPublishDate = DateTime.SpecifyKind(DateTime.ParseExact(YearStr, "yyyy", CultureInfo.InvariantCulture), DateTimeKind.Unspecified);

View File

@ -1,26 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net452</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Indexers\**" />
<EmbeddedResource Remove="Indexers\**" />
<None Remove="Indexers\**" />
</ItemGroup>
<ItemGroup>
<None Remove="Util\Invalid-RSS.xml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Util\Invalid-RSS.xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="4.6.2" />
<PackageReference Include="FluentAssertions" Version="4.19.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.2.0" />
@ -29,17 +24,14 @@
<PackageReference Include="NUnit.ConsoleRunner" Version="3.7.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.9.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Jackett.Common\Jackett.Common.csproj" />
<ProjectReference Include="..\Jackett\Jackett.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Web" />
</ItemGroup>
</Project>
</Project>