From 3fab8fb0db0f4831f2c9d325320b61686330c44d Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sun, 16 Jul 2023 17:04:08 +0300 Subject: [PATCH] Fixed: (Search) Ensure TvMazeId is parsed correctly on a repeat search --- .../Definitions/TvSearchCriteria.cs | 30 ++++++++++++++----- .../IndexerSearch/NewznabRequest.cs | 9 ++++-- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/NzbDrone.Core/IndexerSearch/Definitions/TvSearchCriteria.cs b/src/NzbDrone.Core/IndexerSearch/Definitions/TvSearchCriteria.cs index 1e4c35e5b..a79878a98 100644 --- a/src/NzbDrone.Core/IndexerSearch/Definitions/TvSearchCriteria.cs +++ b/src/NzbDrone.Core/IndexerSearch/Definitions/TvSearchCriteria.cs @@ -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}"; } } diff --git a/src/NzbDrone.Core/IndexerSearch/NewznabRequest.cs b/src/NzbDrone.Core/IndexerSearch/NewznabRequest.cs index 8fb138fcf..bddfc4de4 100644 --- a/src/NzbDrone.Core/IndexerSearch/NewznabRequest.cs +++ b/src/NzbDrone.Core/IndexerSearch/NewznabRequest.cs @@ -5,7 +5,7 @@ namespace NzbDrone.Core.IndexerSearch { public class NewznabRequest { - private static readonly Regex TvRegex = new (@"\{((?:imdbid\:)(?[^{]+)|(?:rid\:)(?[^{]+)|(?:tvdbid\:)(?[^{]+)|(?:tmdbid\:)(?[^{]+)|(?:doubanid\:)(?[^{]+)|(?:season\:)(?[^{]+)|(?:episode\:)(?[^{]+)|(?:year\:)(?[^{]+)|(?:genre\:)(?[^{]+))\}", RegexOptions.Compiled | RegexOptions.IgnoreCase); + private static readonly Regex TvRegex = new (@"\{((?:imdbid\:)(?[^{]+)|(?:rid\:)(?[^{]+)|(?:tvdbid\:)(?[^{]+)|(?:tmdbid\:)(?[^{]+)|(?:tvmazeid\:)(?[^{]+)|(?:doubanid\:)(?[^{]+)|(?:season\:)(?[^{]+)|(?:episode\:)(?[^{]+)|(?:year\:)(?[^{]+)|(?:genre\:)(?[^{]+))\}", RegexOptions.Compiled | RegexOptions.IgnoreCase); private static readonly Regex MovieRegex = new (@"\{((?:imdbid\:)(?[^{]+)|(?:doubanid\:)(?[^{]+)|(?:tmdbid\:)(?[^{]+)|(?:traktid\:)(?[^{]+)|(?:year\:)(?[^{]+)|(?:genre\:)(?[^{]+))\}", RegexOptions.Compiled | RegexOptions.IgnoreCase); private static readonly Regex MusicRegex = new (@"\{((?:artist\:)(?[^{]+)|(?:album\:)(?[^{]+)|(?:track\:)(?[^{]+)|(?:label\:)(?