Animebytes: add AddSynonyms and FilterSeasonEpisode options

This commit is contained in:
kaso17 2017-10-17 11:15:09 +02:00
parent 851a4d30e1
commit 63cf687f02
2 changed files with 33 additions and 5 deletions

View File

@ -35,6 +35,8 @@ namespace Jackett.Indexers
private string MusicSearchUrl { get { return SiteLink + "torrents2.php?"; } }
public bool AllowRaws { get { return configData.IncludeRaw.Value; } }
public bool InsertSeason { get { return configData.InsertSeason != null && configData.InsertSeason.Value; } }
public bool AddSynonyms { get { return configData.AddSynonyms.Value; } }
public bool FilterSeasonEpisode { get { return configData.FilterSeasonEpisode.Value; } }
new ConfigurationDataAnimeBytes configData
{
@ -136,13 +138,13 @@ namespace Jackett.Indexers
if (ContainsMusicCategories(query.Categories))
{
foreach (var result in await GetResults(SearchType.Audio, query.SanitizedSearchTerm))
foreach (var result in await GetResults(query, SearchType.Audio, query.SanitizedSearchTerm))
{
releases.Add(result);
}
}
foreach (var result in await GetResults(SearchType.Video, StripEpisodeNumber(query.SanitizedSearchTerm)))
foreach (var result in await GetResults(query, SearchType.Video, StripEpisodeNumber(query.SanitizedSearchTerm)))
{
releases.Add(result);
}
@ -164,7 +166,7 @@ namespace Jackett.Indexers
return categories.Length == 0 || music.Any(categories.Contains);
}
private async Task<IEnumerable<ReleaseInfo>> GetResults(SearchType searchType, string searchTerm)
private async Task<IEnumerable<ReleaseInfo>> GetResults(TorznabQuery query, SearchType searchType, string searchTerm)
{
var cleanSearchTerm = HttpUtility.UrlEncode(searchTerm);
@ -232,7 +234,7 @@ namespace Jackett.Indexers
synonyms.Add(mainTitle);
// If the title contains a comma then we can't use the synonyms as they are comma seperated
if (!mainTitle.Contains(","))
if (!mainTitle.Contains(",") && AddSynonyms)
{
var symnomnNames = string.Empty;
foreach (var e in seriesCq.Find(".group_statbox li"))
@ -259,16 +261,20 @@ namespace Jackett.Indexers
foreach (var title in synonyms)
{
var releaseRows = seriesCq.Find(".torrent_group tr");
string episode = null;
int? season = null;
// Skip the first two info rows
for (int r = 1; r < releaseRows.Count(); r++)
{
var row = releaseRows.Get(r);
var rowCq = row.Cq();
if (rowCq.HasClass("edition_info"))
{
episode = null;
season = null;
releaseInfo = rowCq.Find("td").Text();
if (string.IsNullOrWhiteSpace(releaseInfo))
{
// Single episodes alpha - Reported that this info is missing.
@ -276,6 +282,16 @@ namespace Jackett.Indexers
break;
}
Regex SeasonRegEx = new Regex(@"Season (\d+)", RegexOptions.Compiled);
var SeasonRegExMatch = SeasonRegEx.Match(releaseInfo);
if (SeasonRegExMatch.Success)
season = ParseUtil.CoerceInt(SeasonRegExMatch.Groups[1].Value);
Regex EpisodeRegEx = new Regex(@"Episode (\d+)", RegexOptions.Compiled);
var EpisodeRegExMatch = EpisodeRegEx.Match(releaseInfo);
if (EpisodeRegExMatch.Success)
episode = EpisodeRegExMatch.Groups[1].Value;
releaseInfo = releaseInfo.Replace("Episode ", "");
releaseInfo = releaseInfo.Replace("Season ", "S");
releaseInfo = releaseInfo.Trim();
@ -295,6 +311,14 @@ namespace Jackett.Indexers
continue;
}
if (FilterSeasonEpisode)
{
if (query.Season != 0 && season != null && season != query.Season) // skip if season doesn't match
continue;
if (query.Episode != null && episode != null && episode != query.Episode) // skip if episode doesn't match
continue;
}
var release = new ReleaseInfo();
release.MinimumRatio = 1;
release.MinimumSeedTime = 259200;

View File

@ -12,6 +12,8 @@ namespace Jackett.Models.IndexerConfig.Bespoke
public BoolItem IncludeRaw { get; private set; }
public DisplayItem DateWarning { get; private set; }
public BoolItem InsertSeason { get; private set; }
public BoolItem AddSynonyms { get; private set; }
public BoolItem FilterSeasonEpisode { get; private set; }
public ConfigurationDataAnimeBytes()
: base()
@ -19,6 +21,8 @@ namespace Jackett.Models.IndexerConfig.Bespoke
IncludeRaw = new BoolItem() { Name = "IncludeRaw", Value = false };
DateWarning = new DisplayItem("This tracker does not supply upload dates so they are based off year of release.") { Name = "DateWarning" };
InsertSeason = new BoolItem() { Name = "Prefix episode number with E0 for Sonarr Compatability", Value = false };
AddSynonyms = new BoolItem() { Name = "Add releases for each synonym title", Value = true };
FilterSeasonEpisode = new BoolItem() { Name = "Filter results by season/episode", Value = false };
}
}
}