aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs6
-rw-r--r--MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs14
-rw-r--r--tests/Jellyfin.Providers.Tests/Tmdb/TmdbUtilsTests.cs13
3 files changed, 30 insertions, 3 deletions
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs b/MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs
index fb3e5ee92b..6b1b54ce02 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs
@@ -568,8 +568,8 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
return null;
}
- // Use "original" as default size if size is null or empty to prevent malformed URLs
- var imageSize = string.IsNullOrEmpty(size) ? "original" : size;
+ // Use the original size as default if size is null or empty to prevent malformed URLs
+ var imageSize = string.IsNullOrEmpty(size) ? TmdbUtils.OriginalImageSize : size;
return _tmDbClient.GetImageUrl(imageSize, path, true).ToString();
}
@@ -660,7 +660,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
private IEnumerable<RemoteImageInfo> ConvertToRemoteImageInfo(IReadOnlyList<ImageData> images, string? size, ImageType type, string requestLanguage)
{
// sizes provided are for original resolution, don't store them when downloading scaled images
- var scaleImage = !string.Equals(size, "original", StringComparison.OrdinalIgnoreCase);
+ var scaleImage = !TmdbUtils.IsOriginalImageSize(size);
for (var i = 0; i < images.Count; i++)
{
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs b/MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs
index a002140d1e..f004251594 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/TmdbUtils.cs
@@ -34,6 +34,11 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
/// </summary>
public const string ApiKey = "4219e299c89411838049ab0dab19ebd5";
+ /// <summary>
+ /// The image size representing the unscaled image as served by TMDb.
+ /// </summary>
+ public const string OriginalImageSize = "original";
+
private const int TitleExactScore = 8;
private const int TitlePrefixScore = 4;
private const int YearExactScore = 2;
@@ -486,6 +491,15 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
}
/// <summary>
+ /// Determines whether the configured image size fetches the image at its original resolution.
+ /// An unset size falls back to <see cref="OriginalImageSize"/>, see TmdbClientManager.GetUrl.
+ /// </summary>
+ /// <param name="size">The configured image size.</param>
+ /// <returns><c>true</c> if the original image is fetched; otherwise, <c>false</c>.</returns>
+ public static bool IsOriginalImageSize(string? size)
+ => string.IsNullOrEmpty(size) || string.Equals(size, OriginalImageSize, StringComparison.OrdinalIgnoreCase);
+
+ /// <summary>
/// Combines the metadata country code and the parental rating from the API into the value we store in our database.
/// </summary>
/// <param name="countryCode">The ISO 3166-1 country code of the rating country.</param>
diff --git a/tests/Jellyfin.Providers.Tests/Tmdb/TmdbUtilsTests.cs b/tests/Jellyfin.Providers.Tests/Tmdb/TmdbUtilsTests.cs
index 8926a7b13c..03bad3555e 100644
--- a/tests/Jellyfin.Providers.Tests/Tmdb/TmdbUtilsTests.cs
+++ b/tests/Jellyfin.Providers.Tests/Tmdb/TmdbUtilsTests.cs
@@ -105,6 +105,19 @@ namespace Jellyfin.Providers.Tests.Tmdb
}
[Theory]
+ // An unconfigured size fetches the original image, so it keeps the original resolution.
+ [InlineData(null, true)]
+ [InlineData("", true)]
+ [InlineData("original", true)]
+ [InlineData("Original", true)]
+ [InlineData("w500", false)]
+ [InlineData("original2", false)]
+ public static void IsOriginalImageSize_Valid_Success(string? size, bool expected)
+ {
+ Assert.Equal(expected, TmdbUtils.IsOriginalImageSize(size));
+ }
+
+ [Theory]
[MemberData(nameof(FindBestMatch_Movies_TestData))]
public static void FindBestMatch_Movies_PicksExpected(string description, string name, int year, IReadOnlyList<SearchMovie> results, int expectedId)
{