From d720d8f3569a0db11ba170c92d8d4ff055c4eaa9 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 20 Dec 2019 20:04:27 +0100 Subject: [PATCH] Add requested changes --- .../Tmdb/TV/TmdbSeasonImageProvider.cs | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/MediaBrowser.Providers/Tmdb/TV/TmdbSeasonImageProvider.cs b/MediaBrowser.Providers/Tmdb/TV/TmdbSeasonImageProvider.cs index 51db2fb13..f0b2cd88e 100644 --- a/MediaBrowser.Providers/Tmdb/TV/TmdbSeasonImageProvider.cs +++ b/MediaBrowser.Providers/Tmdb/TV/TmdbSeasonImageProvider.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -22,15 +23,11 @@ namespace MediaBrowser.Providers.Tmdb.TV { private readonly IJsonSerializer _jsonSerializer; private readonly IHttpClient _httpClient; - private readonly IFileSystem _fileSystem; - private readonly ILocalizationManager _localization; - public TmdbSeasonImageProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient, IFileSystem fileSystem, ILocalizationManager localization) + public TmdbSeasonImageProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient) { _jsonSerializer = jsonSerializer; _httpClient = httpClient; - _fileSystem = fileSystem; - _localization = localization; } public int Order => 1; @@ -69,7 +66,7 @@ namespace MediaBrowser.Providers.Tmdb.TV var language = item.GetPreferredMetadataLanguage(); - var results = await FetchImages(season, seriesId, language, _jsonSerializer, cancellationToken).ConfigureAwait(false); + var results = await FetchImages(season, seriesId, language, cancellationToken).ConfigureAwait(false); var tmdbSettings = await TmdbMovieProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false); @@ -86,7 +83,7 @@ namespace MediaBrowser.Providers.Tmdb.TV ProviderName = Name, Type = ImageType.Primary, RatingType = RatingType.Score - }).ToList(); + }); var isLanguageEn = string.Equals(language, "en", StringComparison.OrdinalIgnoreCase); @@ -96,6 +93,7 @@ namespace MediaBrowser.Providers.Tmdb.TV { return 3; } + if (!isLanguageEn) { if (string.Equals("en", i.Language, StringComparison.OrdinalIgnoreCase)) @@ -103,18 +101,19 @@ namespace MediaBrowser.Providers.Tmdb.TV return 2; } } + if (string.IsNullOrEmpty(i.Language)) { return isLanguageEn ? 3 : 2; } + return 0; }) .ThenByDescending(i => i.CommunityRating ?? 0) .ThenByDescending(i => i.VoteCount ?? 0); } - private async Task> FetchImages(Season item, string tmdbId, string language, IJsonSerializer jsonSerializer, - CancellationToken cancellationToken) + private async Task> FetchImages(Season item, string tmdbId, string language, CancellationToken cancellationToken) { await TmdbSeasonProvider.Current.EnsureSeasonInfo(tmdbId, item.IndexNumber.GetValueOrDefault(), language, cancellationToken).ConfigureAwait(false); @@ -122,11 +121,9 @@ namespace MediaBrowser.Providers.Tmdb.TV if (!string.IsNullOrEmpty(path)) { - var fileInfo = _fileSystem.GetFileInfo(path); - - if (fileInfo.Exists) + if (File.Exists(path)) { - return jsonSerializer.DeserializeFromFile(path).Images.Posters; + return _jsonSerializer.DeserializeFromFile(path).Images.Posters; } }