Applied 2nd Round of Suggested Changes

pull/10078/head
LJQ 1 year ago
parent da1bd4a4a5
commit 298a7488a3

@ -104,36 +104,26 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
return metadataResult;
}
var episodeResult = new TvEpisode();
if (!info.IndexNumberEnd.HasValue)
{
episodeResult = await _tmdbClientManager
.GetEpisodeAsync(seriesTmdbId, seasonNumber.Value, episodeNumber.Value, info.SeriesDisplayOrder, info.MetadataLanguage, TmdbUtils.GetImageLanguagesParam(info.MetadataLanguage), cancellationToken)
.ConfigureAwait(false);
}
else
TvEpisode? episodeResult = null;
if (info.IndexNumberEnd.HasValue)
{
var startindex = episodeNumber;
var endindex = info.IndexNumberEnd;
List<TvEpisode> result = new List<TvEpisode>();
List<TvEpisode>? result = null;
for (int? episode = startindex; episode <= endindex; episode++)
{
var episodeInfo = await _tmdbClientManager.GetEpisodeAsync(seriesTmdbId, seasonNumber.Value, episode.Value, info.SeriesDisplayOrder, info.MetadataLanguage, TmdbUtils.GetImageLanguagesParam(info.MetadataLanguage), cancellationToken).ConfigureAwait(false);
if (episodeInfo is not null)
{
result.Add(episodeInfo);
(result ??= new List<TvEpisode>()).Add(episodeInfo);
}
}
if (result.Count > 0)
if (result is not null)
{
episodeResult = result[0];
}
else
if (result.Count > 1)
{
return metadataResult;
}
var name = new StringBuilder(episodeResult.Name);
var overview = new StringBuilder(episodeResult.Overview);
@ -146,6 +136,18 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
episodeResult.Name = name.ToString();
episodeResult.Overview = overview.ToString();
}
}
else
{
return metadataResult;
}
}
else
{
episodeResult = await _tmdbClientManager
.GetEpisodeAsync(seriesTmdbId, seasonNumber.Value, episodeNumber.Value, info.SeriesDisplayOrder, info.MetadataLanguage, TmdbUtils.GetImageLanguagesParam(info.MetadataLanguage), cancellationToken)
.ConfigureAwait(false);
}
if (episodeResult is null)
{

Loading…
Cancel
Save