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; return metadataResult;
} }
var episodeResult = new TvEpisode(); TvEpisode? episodeResult = null;
if (!info.IndexNumberEnd.HasValue) 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
{ {
var startindex = episodeNumber; var startindex = episodeNumber;
var endindex = info.IndexNumberEnd; var endindex = info.IndexNumberEnd;
List<TvEpisode> result = new List<TvEpisode>(); List<TvEpisode>? result = null;
for (int? episode = startindex; episode <= endindex; episode++) 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); 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) 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]; episodeResult = result[0];
} if (result.Count > 1)
else
{ {
return metadataResult;
}
var name = new StringBuilder(episodeResult.Name); var name = new StringBuilder(episodeResult.Name);
var overview = new StringBuilder(episodeResult.Overview); var overview = new StringBuilder(episodeResult.Overview);
@ -146,6 +136,18 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
episodeResult.Name = name.ToString(); episodeResult.Name = name.ToString();
episodeResult.Overview = overview.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) if (episodeResult is null)
{ {

Loading…
Cancel
Save