mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Animebytes: add AddSynonyms and FilterSeasonEpisode options
This commit is contained in:
@@ -35,6 +35,8 @@ namespace Jackett.Indexers
|
|||||||
private string MusicSearchUrl { get { return SiteLink + "torrents2.php?"; } }
|
private string MusicSearchUrl { get { return SiteLink + "torrents2.php?"; } }
|
||||||
public bool AllowRaws { get { return configData.IncludeRaw.Value; } }
|
public bool AllowRaws { get { return configData.IncludeRaw.Value; } }
|
||||||
public bool InsertSeason { get { return configData.InsertSeason != null && configData.InsertSeason.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
|
new ConfigurationDataAnimeBytes configData
|
||||||
{
|
{
|
||||||
@@ -136,13 +138,13 @@ namespace Jackett.Indexers
|
|||||||
|
|
||||||
if (ContainsMusicCategories(query.Categories))
|
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);
|
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);
|
releases.Add(result);
|
||||||
}
|
}
|
||||||
@@ -164,7 +166,7 @@ namespace Jackett.Indexers
|
|||||||
return categories.Length == 0 || music.Any(categories.Contains);
|
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);
|
var cleanSearchTerm = HttpUtility.UrlEncode(searchTerm);
|
||||||
|
|
||||||
@@ -232,7 +234,7 @@ namespace Jackett.Indexers
|
|||||||
synonyms.Add(mainTitle);
|
synonyms.Add(mainTitle);
|
||||||
|
|
||||||
// If the title contains a comma then we can't use the synonyms as they are comma seperated
|
// 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;
|
var symnomnNames = string.Empty;
|
||||||
foreach (var e in seriesCq.Find(".group_statbox li"))
|
foreach (var e in seriesCq.Find(".group_statbox li"))
|
||||||
@@ -259,16 +261,20 @@ namespace Jackett.Indexers
|
|||||||
foreach (var title in synonyms)
|
foreach (var title in synonyms)
|
||||||
{
|
{
|
||||||
var releaseRows = seriesCq.Find(".torrent_group tr");
|
var releaseRows = seriesCq.Find(".torrent_group tr");
|
||||||
|
string episode = null;
|
||||||
|
int? season = null;
|
||||||
|
|
||||||
// Skip the first two info rows
|
// Skip the first two info rows
|
||||||
for (int r = 1; r < releaseRows.Count(); r++)
|
for (int r = 1; r < releaseRows.Count(); r++)
|
||||||
{
|
{
|
||||||
|
|
||||||
var row = releaseRows.Get(r);
|
var row = releaseRows.Get(r);
|
||||||
var rowCq = row.Cq();
|
var rowCq = row.Cq();
|
||||||
if (rowCq.HasClass("edition_info"))
|
if (rowCq.HasClass("edition_info"))
|
||||||
{
|
{
|
||||||
|
episode = null;
|
||||||
|
season = null;
|
||||||
releaseInfo = rowCq.Find("td").Text();
|
releaseInfo = rowCq.Find("td").Text();
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(releaseInfo))
|
if (string.IsNullOrWhiteSpace(releaseInfo))
|
||||||
{
|
{
|
||||||
// Single episodes alpha - Reported that this info is missing.
|
// Single episodes alpha - Reported that this info is missing.
|
||||||
@@ -276,6 +282,16 @@ namespace Jackett.Indexers
|
|||||||
break;
|
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("Episode ", "");
|
||||||
releaseInfo = releaseInfo.Replace("Season ", "S");
|
releaseInfo = releaseInfo.Replace("Season ", "S");
|
||||||
releaseInfo = releaseInfo.Trim();
|
releaseInfo = releaseInfo.Trim();
|
||||||
@@ -295,6 +311,14 @@ namespace Jackett.Indexers
|
|||||||
continue;
|
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();
|
var release = new ReleaseInfo();
|
||||||
release.MinimumRatio = 1;
|
release.MinimumRatio = 1;
|
||||||
release.MinimumSeedTime = 259200;
|
release.MinimumSeedTime = 259200;
|
||||||
|
@@ -12,6 +12,8 @@ namespace Jackett.Models.IndexerConfig.Bespoke
|
|||||||
public BoolItem IncludeRaw { get; private set; }
|
public BoolItem IncludeRaw { get; private set; }
|
||||||
public DisplayItem DateWarning { get; private set; }
|
public DisplayItem DateWarning { get; private set; }
|
||||||
public BoolItem InsertSeason { get; private set; }
|
public BoolItem InsertSeason { get; private set; }
|
||||||
|
public BoolItem AddSynonyms { get; private set; }
|
||||||
|
public BoolItem FilterSeasonEpisode { get; private set; }
|
||||||
|
|
||||||
public ConfigurationDataAnimeBytes()
|
public ConfigurationDataAnimeBytes()
|
||||||
: base()
|
: base()
|
||||||
@@ -19,6 +21,8 @@ namespace Jackett.Models.IndexerConfig.Bespoke
|
|||||||
IncludeRaw = new BoolItem() { Name = "IncludeRaw", Value = false };
|
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" };
|
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 };
|
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 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user