diff --git a/src/Sonarr.Api.V3/Series/SeriesModule.cs b/src/Sonarr.Api.V3/Series/SeriesModule.cs index fb39a39dc..016a6dd53 100644 --- a/src/Sonarr.Api.V3/Series/SeriesModule.cs +++ b/src/Sonarr.Api.V3/Series/SeriesModule.cs @@ -99,9 +99,19 @@ namespace Sonarr.Api.V3.Series private List AllSeries() { + var tvdbId = Request.GetIntegerQueryParameter("tvdbId"); var includeSeasonImages = Request.GetBooleanQueryParameter("includeSeasonImages"); var seriesStats = _seriesStatisticsService.SeriesStatistics(); - var seriesResources = _seriesService.GetAllSeries().Select(s => s.ToResource(includeSeasonImages)).ToList(); + var seriesResources = new List(); + + if (tvdbId > 0) + { + seriesResources.AddIfNotNull(_seriesService.FindByTvdbId(tvdbId).ToResource(includeSeasonImages)); + } + else + { + seriesResources.AddRange(_seriesService.GetAllSeries().Select(s => s.ToResource(includeSeasonImages))); + } MapCoversToLocal(seriesResources.ToArray()); LinkSeriesStatistics(seriesResources, seriesStats); diff --git a/src/Sonarr.Http/Extensions/RequestExtensions.cs b/src/Sonarr.Http/Extensions/RequestExtensions.cs index 84843494e..dbb518384 100644 --- a/src/Sonarr.Http/Extensions/RequestExtensions.cs +++ b/src/Sonarr.Http/Extensions/RequestExtensions.cs @@ -54,5 +54,17 @@ namespace Sonarr.Http.Extensions return defaultValue; } + + public static int GetIntegerQueryParameter(this Request request, string parameter, int defaultValue = 0) + { + var parameterValue = request.Query[parameter]; + + if (parameterValue.HasValue) + { + return int.Parse(parameterValue.Value); + } + + return defaultValue; + } } }