Applied 2nd Round of Suggested Changes

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

@ -104,47 +104,49 @@ 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)
{
var name = new StringBuilder(episodeResult.Name);
var overview = new StringBuilder(episodeResult.Overview);
for (int i = 1; i < result.Count; i++)
{
name.Append(" / ").Append(result[i].Name);
overview.Append(" / ").Append(result[i].Overview);
}
episodeResult.Name = name.ToString();
episodeResult.Overview = overview.ToString();
}
} }
else else
{ {
return metadataResult; return metadataResult;
} }
}
var name = new StringBuilder(episodeResult.Name); else
var overview = new StringBuilder(episodeResult.Overview); {
episodeResult = await _tmdbClientManager
for (int i = 1; i < result.Count; i++) .GetEpisodeAsync(seriesTmdbId, seasonNumber.Value, episodeNumber.Value, info.SeriesDisplayOrder, info.MetadataLanguage, TmdbUtils.GetImageLanguagesParam(info.MetadataLanguage), cancellationToken)
{ .ConfigureAwait(false);
name.Append(" / ").Append(result[i].Name);
overview.Append(" / ").Append(result[i].Overview);
}
episodeResult.Name = name.ToString();
episodeResult.Overview = overview.ToString();
} }
if (episodeResult is null) if (episodeResult is null)

Loading…
Cancel
Save