TmdbClientConfiguration()
+ {
+ return (await _tmdbClientManager.GetClientConfiguration().ConfigureAwait(false)).Images;
+ }
+ }
+}
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/Configuration/PluginConfiguration.cs b/MediaBrowser.Providers/Plugins/Tmdb/Configuration/PluginConfiguration.cs
index 9a78a7536..dec796148 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/Configuration/PluginConfiguration.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/Configuration/PluginConfiguration.cs
@@ -26,5 +26,25 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
/// Gets or sets a value indicating the maximum number of cast members to fetch for an item.
///
public int MaxCastMembers { get; set; } = 15;
+
+ ///
+ /// Gets or sets a value indicating the poster image size to fetch.
+ ///
+ public string? PosterSize { get; set; }
+
+ ///
+ /// Gets or sets a value indicating the backdrop image size to fetch.
+ ///
+ public string? BackdropSize { get; set; }
+
+ ///
+ /// Gets or sets a value indicating the profile image size to fetch.
+ ///
+ public string? ProfileSize { get; set; }
+
+ ///
+ /// Gets or sets a value indicating the still image size to fetch.
+ ///
+ public string? StillSize { get; set; }
}
}
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/Configuration/config.html b/MediaBrowser.Providers/Plugins/Tmdb/Configuration/config.html
index 12b4c7ca4..52693795b 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/Configuration/config.html
+++ b/MediaBrowser.Providers/Plugins/Tmdb/Configuration/config.html
@@ -24,7 +24,21 @@
The maximum number of cast members to fetch for an item.
-
+
@@ -39,6 +53,47 @@
document.querySelector('.configPage')
.addEventListener('pageshow', function () {
Dashboard.showLoadingMsg();
+
+ var clientConfig, pluginConfig;
+ var configureImageScaling = function() {
+ if (clientConfig === null || pluginConfig === null) {
+ return;
+ }
+
+ var sizeOptionsGenerator = function (size) {
+ return '';
+ }
+
+ var selPosterSize = document.querySelector('#selectPosterSize');
+ selPosterSize.innerHTML = clientConfig.PosterSizes.map(sizeOptionsGenerator);
+ selPosterSize.value = pluginConfig.PosterSize;
+
+ var selBackdropSize = document.querySelector('#selectBackdropSize');
+ selBackdropSize.innerHTML = clientConfig.BackdropSizes.map(sizeOptionsGenerator);
+ selBackdropSize.value = pluginConfig.BackdropSize;
+
+ var selProfileSize = document.querySelector('#selectProfileSize');
+ selProfileSize.innerHTML = clientConfig.ProfileSizes.map(sizeOptionsGenerator);
+ selProfileSize.value = pluginConfig.ProfileSize;
+
+ var selStillSize = document.querySelector('#selectStillSize');
+ selStillSize.innerHTML = clientConfig.StillSizes.map(sizeOptionsGenerator);
+ selStillSize.value = pluginConfig.StillSize;
+
+ Dashboard.hideLoadingMsg();
+ }
+
+ const request = {
+ url: ApiClient.getUrl('tmdb/ClientConfiguration'),
+ dataType: 'json',
+ type: 'GET',
+ headers: { accept: 'application/json' }
+ }
+ ApiClient.fetch(request).then(function (config) {
+ clientConfig = config;
+ configureImageScaling();
+ });
+
ApiClient.getPluginConfiguration(PluginConfig.pluginId).then(function (config) {
document.querySelector('#includeAdult').checked = config.IncludeAdult;
document.querySelector('#excludeTagsSeries').checked = config.ExcludeTagsSeries;
@@ -51,7 +106,8 @@
cancelable: false
}));
- Dashboard.hideLoadingMsg();
+ pluginConfig = config;
+ configureImageScaling();
});
});
@@ -65,6 +121,10 @@
config.ExcludeTagsSeries = document.querySelector('#excludeTagsSeries').checked;
config.ExcludeTagsMovies = document.querySelector('#excludeTagsMovies').checked;
config.MaxCastMembers = document.querySelector('#maxCastMembers').value;
+ config.PosterSize = document.querySelector('#selectPosterSize').value;
+ config.BackdropSize = document.querySelector('#selectBackdropSize').value;
+ config.ProfileSize = document.querySelector('#selectProfileSize').value;
+ config.StillSize = document.querySelector('#selectStillSize').value;
ApiClient.updatePluginConfiguration(PluginConfig.pluginId, config).then(Dashboard.processPluginConfigurationUpdateResult);
});
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs b/MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs
index 4d3bc61e5..28d6f4d0c 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs
@@ -508,7 +508,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
/// The absolute URL.
public string GetPosterUrl(string posterPath)
{
- return GetUrl(_tmDbClient.Config.Images.PosterSizes[^1], posterPath);
+ return GetUrl(Plugin.Instance.Configuration.PosterSize, posterPath);
}
///
@@ -518,7 +518,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
/// The absolute URL.
public string GetProfileUrl(string actorProfilePath)
{
- return GetUrl(_tmDbClient.Config.Images.ProfileSizes[^1], actorProfilePath);
+ return GetUrl(Plugin.Instance.Configuration.ProfileSize, actorProfilePath);
}
///
@@ -529,7 +529,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
/// The collection to add the remote images into.
public void ConvertPostersToRemoteImageInfo(List images, string requestLanguage, List results)
{
- ConvertToRemoteImageInfo(images, _tmDbClient.Config.Images.PosterSizes[^1], ImageType.Primary, requestLanguage, results);
+ ConvertToRemoteImageInfo(images, Plugin.Instance.Configuration.PosterSize, ImageType.Primary, requestLanguage, results);
}
///
@@ -540,7 +540,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
/// The collection to add the remote images into.
public void ConvertBackdropsToRemoteImageInfo(List images, string requestLanguage, List results)
{
- ConvertToRemoteImageInfo(images, _tmDbClient.Config.Images.BackdropSizes[^1], ImageType.Backdrop, requestLanguage, results);
+ ConvertToRemoteImageInfo(images, Plugin.Instance.Configuration.BackdropSize, ImageType.Backdrop, requestLanguage, results);
}
///
@@ -551,7 +551,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
/// The collection to add the remote images into.
public void ConvertProfilesToRemoteImageInfo(List images, string requestLanguage, List results)
{
- ConvertToRemoteImageInfo(images, _tmDbClient.Config.Images.ProfileSizes[^1], ImageType.Primary, requestLanguage, results);
+ ConvertToRemoteImageInfo(images, Plugin.Instance.Configuration.ProfileSize, ImageType.Primary, requestLanguage, results);
}
///
@@ -562,7 +562,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
/// The collection to add the remote images into.
public void ConvertStillsToRemoteImageInfo(List images, string requestLanguage, List results)
{
- ConvertToRemoteImageInfo(images, _tmDbClient.Config.Images.StillSizes[^1], ImageType.Primary, requestLanguage, results);
+ ConvertToRemoteImageInfo(images, Plugin.Instance.Configuration.StillSize, ImageType.Primary, requestLanguage, results);
}
///
@@ -575,16 +575,20 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
/// The collection to add the remote images into.
private void ConvertToRemoteImageInfo(List images, string size, ImageType type, string requestLanguage, List results)
{
+ // sizes provided are for original resolution, don't store them when downloading scaled images
+ var scaleImage = !string.Equals(size, "original", StringComparison.OrdinalIgnoreCase);
+
for (var i = 0; i < images.Count; i++)
{
var image = images[i];
+
results.Add(new RemoteImageInfo
{
Url = GetUrl(size, image.FilePath),
CommunityRating = image.VoteAverage,
VoteCount = image.VoteCount,
- Width = image.Width,
- Height = image.Height,
+ Width = scaleImage ? null : image.Width,
+ Height = scaleImage ? null : image.Height,
Language = TmdbUtils.AdjustImageLanguage(image.Iso_639_1, requestLanguage),
ProviderName = TmdbUtils.ProviderName,
Type = type,
@@ -593,9 +597,51 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
}
}
- private Task EnsureClientConfigAsync()
+ private async Task EnsureClientConfigAsync()
{
- return !_tmDbClient.HasConfig ? _tmDbClient.GetConfigAsync() : Task.CompletedTask;
+ if (!_tmDbClient.HasConfig)
+ {
+ var config = await _tmDbClient.GetConfigAsync().ConfigureAwait(false);
+ ValidatePreferences(config);
+ }
+ }
+
+ private static void ValidatePreferences(TMDbConfig config)
+ {
+ var imageConfig = config.Images;
+
+ var pluginConfig = Plugin.Instance.Configuration;
+
+ if (!imageConfig.PosterSizes.Contains(pluginConfig.PosterSize))
+ {
+ pluginConfig.PosterSize = imageConfig.PosterSizes[^1];
+ }
+
+ if (!imageConfig.BackdropSizes.Contains(pluginConfig.BackdropSize))
+ {
+ pluginConfig.BackdropSize = imageConfig.BackdropSizes[^1];
+ }
+
+ if (!imageConfig.ProfileSizes.Contains(pluginConfig.ProfileSize))
+ {
+ pluginConfig.ProfileSize = imageConfig.ProfileSizes[^1];
+ }
+
+ if (!imageConfig.StillSizes.Contains(pluginConfig.StillSize))
+ {
+ pluginConfig.StillSize = imageConfig.StillSizes[^1];
+ }
+ }
+
+ ///
+ /// Gets the configuration.
+ ///
+ /// The configuration.
+ public async Task GetClientConfiguration()
+ {
+ await EnsureClientConfigAsync().ConfigureAwait(false);
+
+ return _tmDbClient.Config;
}
///