diff --git a/src/NzbDrone.Core/IndexerSearch/Definitions/TvSearchCriteria.cs b/src/NzbDrone.Core/IndexerSearch/Definitions/TvSearchCriteria.cs index 6bc7367fd..3ccedc245 100644 --- a/src/NzbDrone.Core/IndexerSearch/Definitions/TvSearchCriteria.cs +++ b/src/NzbDrone.Core/IndexerSearch/Definitions/TvSearchCriteria.cs @@ -1,5 +1,6 @@ using System; using System.Globalization; +using NzbDrone.Common.Extensions; using NzbDrone.Core.Parser; namespace NzbDrone.Core.IndexerSearch.Definitions @@ -7,7 +8,7 @@ namespace NzbDrone.Core.IndexerSearch.Definitions public class TvSearchCriteria : SearchCriteriaBase { public int? Season { get; set; } - public int? Ep { get; set; } + public string Episode { get; set; } public string ImdbId { get; set; } public int? TvdbId { get; set; } @@ -25,11 +26,11 @@ namespace NzbDrone.Core.IndexerSearch.Definitions } string episodeString; - if (DateTime.TryParseExact(string.Format("{0} {1}", Season, Ep), "yyyy MM/dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var showDate)) + if (DateTime.TryParseExact(string.Format("{0} {1}", Season, Episode), "yyyy MM/dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var showDate)) { episodeString = showDate.ToString("yyyy.MM.dd"); } - else if (!Ep.HasValue || Ep == 0) + else if (Episode.IsNullOrWhiteSpace()) { episodeString = string.Format("S{0:00}", Season); } @@ -37,11 +38,11 @@ namespace NzbDrone.Core.IndexerSearch.Definitions { try { - episodeString = string.Format("S{0:00}E{1:00}", Season, Ep); + episodeString = string.Format("S{0:00}E{1:00}", Season, ParseUtil.CoerceInt(Episode)); } catch (FormatException) { - episodeString = string.Format("S{0:00}E{1}", Season, Ep); + episodeString = string.Format("S{0:00}E{1}", Season, Episode); } } diff --git a/src/NzbDrone.Core/IndexerSearch/NewznabRequest.cs b/src/NzbDrone.Core/IndexerSearch/NewznabRequest.cs index fa29b359b..f251418e3 100644 --- a/src/NzbDrone.Core/IndexerSearch/NewznabRequest.cs +++ b/src/NzbDrone.Core/IndexerSearch/NewznabRequest.cs @@ -16,7 +16,7 @@ namespace NzbDrone.Core.IndexerSearch public int? traktid { get; set; } public int? tvdbid { get; set; } public int? season { get; set; } - public int? ep { get; set; } + public string ep { get; set; } public string album { get; set; } public string artist { get; set; } public string label { get; set; } diff --git a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs index 589925ec3..3fd8ae756 100644 --- a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs @@ -79,7 +79,7 @@ namespace NzbDrone.Core.IndexerSearch var searchSpec = Get(request, indexerIds, interactiveSearch); searchSpec.Season = request.season; - searchSpec.Ep = request.ep; + searchSpec.Episode = request.ep; searchSpec.TvdbId = request.tvdbid; searchSpec.ImdbId = request.imdbid; searchSpec.TraktId = request.traktid; diff --git a/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetRequestGenerator.cs index 09f02b54e..b36e039f6 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetRequestGenerator.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; using NzbDrone.Core.IndexerSearch.Definitions; @@ -68,14 +69,14 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet } // If only the season/episode is searched for then change format to match expected format - if (searchCriteria.Season > 0 && searchCriteria.Ep == null) + if (searchCriteria.Season > 0 && searchCriteria.Episode == null) { parameters.Name = string.Format("Season {0}%", searchCriteria.Season.Value); parameters.Category = "Season"; } - else if (searchCriteria.Season > 0 && searchCriteria.Ep.Value > 0) + else if (searchCriteria.Season > 0 && int.Parse(searchCriteria.Episode) > 0) { - parameters.Name = string.Format("S{0:00}E{1:00}", searchCriteria.Season.Value, searchCriteria.Ep.Value); + parameters.Name = string.Format("S{0:00}E{1:00}", searchCriteria.Season.Value, int.Parse(searchCriteria.Episode)); parameters.Category = "Episode"; } diff --git a/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannRequestGenerator.cs index 2f50fb2e9..eff9e71f0 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannRequestGenerator.cs @@ -74,7 +74,7 @@ namespace NzbDrone.Core.Indexers.Cardigann var variables = GetQueryVariableDefaults(searchCriteria); variables[".Query.Series"] = null; - variables[".Query.Ep"] = searchCriteria.Ep; + variables[".Query.Ep"] = searchCriteria.Episode; variables[".Query.Season"] = searchCriteria.Season; variables[".Query.IMDBID"] = searchCriteria.ImdbId; variables[".Query.IMDBIDShort"] = searchCriteria.ImdbId?.Replace("tt", "") ?? null; diff --git a/src/NzbDrone.Core/Indexers/Definitions/Newznab/NewznabRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Definitions/Newznab/NewznabRequestGenerator.cs index f0de463aa..611a790c3 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Newznab/NewznabRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Newznab/NewznabRequestGenerator.cs @@ -92,9 +92,9 @@ namespace NzbDrone.Core.Indexers.Newznab parameters += string.Format("&season={0}", searchCriteria.Season); } - if (searchCriteria.Ep.HasValue && capabilities.TvSearchEpAvailable) + if (searchCriteria.Episode.IsNotNullOrWhiteSpace() && capabilities.TvSearchEpAvailable) { - parameters += string.Format("&ep={0}", searchCriteria.Ep); + parameters += string.Format("&ep={0}", searchCriteria.Episode); } if (searchCriteria.SearchTerm.IsNotNullOrWhiteSpace())