mirror of
https://github.com/Prowlarr/Prowlarr
synced 2026-05-08 12:43:19 +02:00
Fix season parsing
This commit is contained in:
parent
59d19f9ae8
commit
6739d14c85
1 changed files with 25 additions and 1 deletions
|
|
@ -179,10 +179,34 @@ private IndexerPageableRequestChain BuildSearch(SearchCriteriaBase searchCriteri
|
|||
var parameters = new NameValueCollection();
|
||||
|
||||
var query = searchCriteria.SearchTerm?.Trim() ?? string.Empty;
|
||||
int? seasonFromQuery = null;
|
||||
|
||||
if (searchCriteria is TvSearchCriteria)
|
||||
var seasonMatch = Regex.Match(query, @"\{season:\s*(\d+)\}", RegexOptions.IgnoreCase);
|
||||
if (seasonMatch.Success)
|
||||
{
|
||||
seasonFromQuery = int.Parse(seasonMatch.Groups[1].Value, CultureInfo.InvariantCulture);
|
||||
query = Regex.Replace(query, @"\{season:\s*\d+\}", "", RegexOptions.IgnoreCase).Trim();
|
||||
}
|
||||
|
||||
var episodeMatch = Regex.Match(query, @"\{episode:\s*(\d+)\}", RegexOptions.IgnoreCase);
|
||||
if (episodeMatch.Success)
|
||||
{
|
||||
query = Regex.Replace(query, @"\{episode:\s*\d+\}", "", RegexOptions.IgnoreCase).Trim();
|
||||
}
|
||||
|
||||
if (searchCriteria is TvSearchCriteria tv)
|
||||
{
|
||||
query = Regex.Replace(query, @"(S\d+E\d+|S\d+)", "", RegexOptions.IgnoreCase).Trim();
|
||||
|
||||
var season = tv.Season ?? seasonFromQuery;
|
||||
if (season.HasValue)
|
||||
{
|
||||
query = $"{query} S{season.Value:00}";
|
||||
}
|
||||
}
|
||||
else if (seasonFromQuery.HasValue)
|
||||
{
|
||||
query = $"{query} S{seasonFromQuery.Value:00}";
|
||||
}
|
||||
|
||||
parameters.Set("searchstr", query);
|
||||
|
|
|
|||
Loading…
Reference in a new issue