From 90b941b3f6646d34f831a2921bc5919bfe9871c0 Mon Sep 17 00:00:00 2001 From: Mohamed Akram Date: Mon, 19 Apr 2021 14:59:24 +0400 Subject: [PATCH] Add review changes --- .../Plugins/Tmdb/TmdbClientManager.cs | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs b/MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs index 3aa673274f..69f9649375 100644 --- a/MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs +++ b/MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs @@ -145,16 +145,8 @@ namespace MediaBrowser.Providers.Plugins.Tmdb /// A comma-separated list of image languages. /// The cancellation token. /// The TMDb tv show episode group information or null if not found. - public async Task GetSeriesGroupAsync(int tvShowId, string displayOrder, string language, string imageLanguages, CancellationToken cancellationToken) + private async Task GetSeriesGroupAsync(int tvShowId, string displayOrder, string language, string imageLanguages, CancellationToken cancellationToken) { - var key = $"group-{tvShowId.ToString(CultureInfo.InvariantCulture)}-{displayOrder}-{language}"; - if (_memoryCache.TryGetValue(key, out TvGroupCollection group)) - { - return group; - } - - await EnsureClientConfigAsync().ConfigureAwait(false); - TvGroupType? groupType = displayOrder == "absolute" ? TvGroupType.Absolute : displayOrder == "dvd" ? TvGroupType.DVD : @@ -165,8 +157,16 @@ namespace MediaBrowser.Providers.Plugins.Tmdb return null; } - var series = await GetSeriesAsync(tvShowId, language, imageLanguages, cancellationToken); - var episodeGroupId = series.EpisodeGroups.Results.Find(g => g.Type == groupType)?.Id; + var key = $"group-{tvShowId.ToString(CultureInfo.InvariantCulture)}-{displayOrder}-{language}"; + if (_memoryCache.TryGetValue(key, out TvGroupCollection group)) + { + return group; + } + + await EnsureClientConfigAsync().ConfigureAwait(false); + + var series = await GetSeriesAsync(tvShowId, language, imageLanguages, cancellationToken).ConfigureAwait(false); + var episodeGroupId = series?.EpisodeGroups.Results.Find(g => g.Type == groupType)?.Id; if (episodeGroupId == null) { @@ -246,6 +246,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb if (group != null) { var season = group.Groups.Find(s => s.Order == seasonNumber); + // Episode order starts at 0 var ep = season?.Episodes.Find(e => e.Order == episodeNumber - 1); if (ep != null) {