mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-12-26 16:26:38 +01:00
Fixed: (Search) Ensure TvMazeId is parsed correctly on a repeat search
This commit is contained in:
@@ -45,14 +45,20 @@ namespace NzbDrone.Core.IndexerSearch.Definitions
|
||||
{
|
||||
get
|
||||
{
|
||||
var searchQueryTerm = $"Term: []";
|
||||
var searchQueryTerm = "Term: []";
|
||||
var searchEpisodeTerm = $" for Season / Episode:[{EpisodeSearchString}]";
|
||||
if (SearchTerm.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
searchQueryTerm = $"Term: [{SearchTerm}]";
|
||||
}
|
||||
|
||||
if (!ImdbId.IsNotNullOrWhiteSpace() && !TvdbId.HasValue && !RId.HasValue && !TraktId.HasValue)
|
||||
if (!ImdbId.IsNotNullOrWhiteSpace() &&
|
||||
!TvdbId.HasValue &&
|
||||
!RId.HasValue &&
|
||||
!TraktId.HasValue &&
|
||||
!TvMazeId.HasValue &&
|
||||
!TmdbId.HasValue &&
|
||||
!DoubanId.HasValue)
|
||||
{
|
||||
return $"{searchQueryTerm}{searchEpisodeTerm}";
|
||||
}
|
||||
@@ -80,11 +86,21 @@ namespace NzbDrone.Core.IndexerSearch.Definitions
|
||||
builder.Append($" TraktId:[{TraktId}]");
|
||||
}
|
||||
|
||||
if (TvMazeId.HasValue)
|
||||
{
|
||||
builder.Append($" TvMazeId:[{TvMazeId}]");
|
||||
}
|
||||
|
||||
if (TmdbId.HasValue)
|
||||
{
|
||||
builder.Append($" TmdbId:[{TmdbId}]");
|
||||
}
|
||||
|
||||
if (DoubanId.HasValue)
|
||||
{
|
||||
builder.Append($" DoubanId:[{DoubanId}]");
|
||||
}
|
||||
|
||||
builder = builder.Append(searchEpisodeTerm);
|
||||
return builder.ToString().Trim();
|
||||
}
|
||||
@@ -92,29 +108,29 @@ namespace NzbDrone.Core.IndexerSearch.Definitions
|
||||
|
||||
private string GetEpisodeSearchString()
|
||||
{
|
||||
if (Season == null || Season == 0)
|
||||
if (Season is null or 0)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
string episodeString;
|
||||
if (DateTime.TryParseExact(string.Format("{0} {1}", Season, Episode), "yyyy MM/dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var showDate))
|
||||
if (DateTime.TryParseExact($"{Season} {Episode}", "yyyy MM/dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var showDate))
|
||||
{
|
||||
episodeString = showDate.ToString("yyyy.MM.dd");
|
||||
}
|
||||
else if (Episode.IsNullOrWhiteSpace())
|
||||
{
|
||||
episodeString = string.Format("S{0:00}", Season);
|
||||
episodeString = $"S{Season:00}";
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
episodeString = string.Format("S{0:00}E{1:00}", Season, ParseUtil.CoerceInt(Episode));
|
||||
episodeString = $"S{Season:00}E{ParseUtil.CoerceInt(Episode):00}";
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
episodeString = string.Format("S{0:00}E{1}", Season, Episode);
|
||||
episodeString = $"S{Season:00}E{Episode}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace NzbDrone.Core.IndexerSearch
|
||||
{
|
||||
public class NewznabRequest
|
||||
{
|
||||
private static readonly Regex TvRegex = new (@"\{((?:imdbid\:)(?<imdbid>[^{]+)|(?:rid\:)(?<rid>[^{]+)|(?:tvdbid\:)(?<tvdbid>[^{]+)|(?:tmdbid\:)(?<tmdbid>[^{]+)|(?:doubanid\:)(?<doubanid>[^{]+)|(?:season\:)(?<season>[^{]+)|(?:episode\:)(?<episode>[^{]+)|(?:year\:)(?<year>[^{]+)|(?:genre\:)(?<genre>[^{]+))\}", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
private static readonly Regex TvRegex = new (@"\{((?:imdbid\:)(?<imdbid>[^{]+)|(?:rid\:)(?<rid>[^{]+)|(?:tvdbid\:)(?<tvdbid>[^{]+)|(?:tmdbid\:)(?<tmdbid>[^{]+)|(?:tvmazeid\:)(?<tvmazeid>[^{]+)|(?:doubanid\:)(?<doubanid>[^{]+)|(?:season\:)(?<season>[^{]+)|(?:episode\:)(?<episode>[^{]+)|(?:year\:)(?<year>[^{]+)|(?:genre\:)(?<genre>[^{]+))\}", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
private static readonly Regex MovieRegex = new (@"\{((?:imdbid\:)(?<imdbid>[^{]+)|(?:doubanid\:)(?<doubanid>[^{]+)|(?:tmdbid\:)(?<tmdbid>[^{]+)|(?:traktid\:)(?<traktid>[^{]+)|(?:year\:)(?<year>[^{]+)|(?:genre\:)(?<genre>[^{]+))\}", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
private static readonly Regex MusicRegex = new (@"\{((?:artist\:)(?<artist>[^{]+)|(?:album\:)(?<album>[^{]+)|(?:track\:)(?<track>[^{]+)|(?:label\:)(?<label>[^{]+)|(?:year\:)(?<year>[^{]+)|(?:genre\:)(?<genre>[^{]+))\}", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
private static readonly Regex BookRegex = new (@"\{((?:author\:)(?<author>[^{]+)|(?:publisher\:)(?<publisher>[^{]+)|(?:title\:)(?<title>[^{]+)|(?:year\:)(?<year>[^{]+)|(?:genre\:)(?<genre>[^{]+))\}", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
@@ -62,6 +62,11 @@ namespace NzbDrone.Core.IndexerSearch
|
||||
tmdbid = int.TryParse(match.Groups["tmdbid"].Value, out var tmdb) ? tmdb : null;
|
||||
}
|
||||
|
||||
if (match.Groups["tvmazeid"].Success)
|
||||
{
|
||||
tvmazeid = int.TryParse(match.Groups["tvmazeid"].Value, out var tvmaze) ? tvmaze : null;
|
||||
}
|
||||
|
||||
if (match.Groups["doubanid"].Success)
|
||||
{
|
||||
doubanid = int.TryParse(match.Groups["doubanid"].Value, out var tmdb) ? tmdb : null;
|
||||
@@ -74,7 +79,7 @@ namespace NzbDrone.Core.IndexerSearch
|
||||
|
||||
if (match.Groups["season"].Success)
|
||||
{
|
||||
season = int.TryParse(match.Groups["season"].Value, out var seasonParsed) ? seasonParsed : null;
|
||||
season = int.TryParse(match.Groups["season"].Value, out var parsedSeason) ? parsedSeason : null;
|
||||
}
|
||||
|
||||
if (match.Groups["imdbid"].Success)
|
||||
|
||||
Reference in New Issue
Block a user