Fixed: Request binding from Sonarr due to string Ep values

pull/10/head
Qstick 4 years ago
parent deded6d073
commit 428c9c034c

@ -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);
}
}

@ -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; }

@ -79,7 +79,7 @@ namespace NzbDrone.Core.IndexerSearch
var searchSpec = Get<TvSearchCriteria>(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;

@ -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";
}

@ -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;

@ -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())

Loading…
Cancel
Save