Merge pull request #7219 from 1337joe/tmdb-image-provider-logo

This commit is contained in:
Cody Robibero 2022-01-20 08:54:07 -07:00 committed by GitHub
commit a4246648f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 40 additions and 5 deletions

View File

@ -22,7 +22,7 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="OptimizedPriorityQueue" Version="5.0.0" /> <PackageReference Include="OptimizedPriorityQueue" Version="5.0.0" />
<PackageReference Include="PlaylistsNET" Version="1.1.3" /> <PackageReference Include="PlaylistsNET" Version="1.1.3" />
<PackageReference Include="TMDbLib" Version="1.8.1" /> <PackageReference Include="TMDbLib" Version="1.9.1" />
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>

View File

@ -42,6 +42,11 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
/// </summary> /// </summary>
public string? BackdropSize { get; set; } public string? BackdropSize { get; set; }
/// <summary>
/// Gets or sets a value indicating the logo image size to fetch.
/// </summary>
public string? LogoSize { get; set; }
/// <summary> /// <summary>
/// Gets or sets a value indicating the profile image size to fetch. /// Gets or sets a value indicating the profile image size to fetch.
/// </summary> /// </summary>

View File

@ -36,6 +36,9 @@
<div class="selectContainer"> <div class="selectContainer">
<select is="emby-select" id="selectBackdropSize" label="Backdrop"></select> <select is="emby-select" id="selectBackdropSize" label="Backdrop"></select>
</div> </div>
<div class="selectContainer">
<select is="emby-select" id="selectLogoSize" label="Logo"></select>
</div>
<div class="selectContainer"> <div class="selectContainer">
<select is="emby-select" id="selectProfileSize" label="Profile"></select> <select is="emby-select" id="selectProfileSize" label="Profile"></select>
</div> </div>
@ -76,6 +79,10 @@
selBackdropSize.innerHTML = clientConfig.BackdropSizes.map(sizeOptionsGenerator); selBackdropSize.innerHTML = clientConfig.BackdropSizes.map(sizeOptionsGenerator);
selBackdropSize.value = pluginConfig.BackdropSize; selBackdropSize.value = pluginConfig.BackdropSize;
var selLogoSize = document.querySelector('#selectLogoSize');
selLogoSize.innerHTML = clientConfig.LogoSizes.map(sizeOptionsGenerator);
selLogoSize.value = pluginConfig.LogoSize;
var selProfileSize = document.querySelector('#selectProfileSize'); var selProfileSize = document.querySelector('#selectProfileSize');
selProfileSize.innerHTML = clientConfig.ProfileSizes.map(sizeOptionsGenerator); selProfileSize.innerHTML = clientConfig.ProfileSizes.map(sizeOptionsGenerator);
selProfileSize.value = pluginConfig.ProfileSize; selProfileSize.value = pluginConfig.ProfileSize;
@ -129,6 +136,7 @@
config.MaxCastMembers = document.querySelector('#maxCastMembers').value; config.MaxCastMembers = document.querySelector('#maxCastMembers').value;
config.PosterSize = document.querySelector('#selectPosterSize').value; config.PosterSize = document.querySelector('#selectPosterSize').value;
config.BackdropSize = document.querySelector('#selectBackdropSize').value; config.BackdropSize = document.querySelector('#selectBackdropSize').value;
config.LogoSize = document.querySelector('#selectLogoSize').value;
config.ProfileSize = document.querySelector('#selectProfileSize').value; config.ProfileSize = document.querySelector('#selectProfileSize').value;
config.StillSize = document.querySelector('#selectStillSize').value; config.StillSize = document.querySelector('#selectStillSize').value;
ApiClient.updatePluginConfiguration(PluginConfig.pluginId, config).then(Dashboard.processPluginConfigurationUpdateResult); ApiClient.updatePluginConfiguration(PluginConfig.pluginId, config).then(Dashboard.processPluginConfigurationUpdateResult);

View File

@ -44,7 +44,8 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
return new List<ImageType> return new List<ImageType>
{ {
ImageType.Primary, ImageType.Primary,
ImageType.Backdrop ImageType.Backdrop,
ImageType.Logo
}; };
} }
@ -85,10 +86,12 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
var posters = movie.Images.Posters; var posters = movie.Images.Posters;
var backdrops = movie.Images.Backdrops; var backdrops = movie.Images.Backdrops;
var remoteImages = new List<RemoteImageInfo>(posters.Count + backdrops.Count); var logos = movie.Images.Logos;
var remoteImages = new List<RemoteImageInfo>(posters.Count + backdrops.Count + logos.Count);
_tmdbClientManager.ConvertPostersToRemoteImageInfo(posters, language, remoteImages); _tmdbClientManager.ConvertPostersToRemoteImageInfo(posters, language, remoteImages);
_tmdbClientManager.ConvertBackdropsToRemoteImageInfo(backdrops, language, remoteImages); _tmdbClientManager.ConvertBackdropsToRemoteImageInfo(backdrops, language, remoteImages);
_tmdbClientManager.ConvertLogosToRemoteImageInfo(logos, language, remoteImages);
return remoteImages; return remoteImages;
} }

View File

@ -42,7 +42,8 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
return new List<ImageType> return new List<ImageType>
{ {
ImageType.Primary, ImageType.Primary,
ImageType.Backdrop ImageType.Backdrop,
ImageType.Logo
}; };
} }
@ -69,10 +70,12 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
var posters = series.Images.Posters; var posters = series.Images.Posters;
var backdrops = series.Images.Backdrops; var backdrops = series.Images.Backdrops;
var remoteImages = new List<RemoteImageInfo>(posters.Count + backdrops.Count); var logos = series.Images.Logos;
var remoteImages = new List<RemoteImageInfo>(posters.Count + backdrops.Count + logos.Count);
_tmdbClientManager.ConvertPostersToRemoteImageInfo(posters, language, remoteImages); _tmdbClientManager.ConvertPostersToRemoteImageInfo(posters, language, remoteImages);
_tmdbClientManager.ConvertBackdropsToRemoteImageInfo(backdrops, language, remoteImages); _tmdbClientManager.ConvertBackdropsToRemoteImageInfo(backdrops, language, remoteImages);
_tmdbClientManager.ConvertLogosToRemoteImageInfo(logos, language, remoteImages);
return remoteImages; return remoteImages;
} }

View File

@ -543,6 +543,17 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
ConvertToRemoteImageInfo(images, Plugin.Instance.Configuration.BackdropSize, ImageType.Backdrop, requestLanguage, results); ConvertToRemoteImageInfo(images, Plugin.Instance.Configuration.BackdropSize, ImageType.Backdrop, requestLanguage, results);
} }
/// <summary>
/// Converts logo <see cref="ImageData"/>s into <see cref="RemoteImageInfo"/>s.
/// </summary>
/// <param name="images">The input images.</param>
/// <param name="requestLanguage">The requested language.</param>
/// <param name="results">The collection to add the remote images into.</param>
public void ConvertLogosToRemoteImageInfo(List<ImageData> images, string requestLanguage, List<RemoteImageInfo> results)
{
ConvertToRemoteImageInfo(images, Plugin.Instance.Configuration.LogoSize, ImageType.Logo, requestLanguage, results);
}
/// <summary> /// <summary>
/// Converts profile <see cref="ImageData"/>s into <see cref="RemoteImageInfo"/>s. /// Converts profile <see cref="ImageData"/>s into <see cref="RemoteImageInfo"/>s.
/// </summary> /// </summary>
@ -622,6 +633,11 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
pluginConfig.BackdropSize = imageConfig.BackdropSizes[^1]; pluginConfig.BackdropSize = imageConfig.BackdropSizes[^1];
} }
if (!imageConfig.LogoSizes.Contains(pluginConfig.LogoSize))
{
pluginConfig.LogoSize = imageConfig.LogoSizes[^1];
}
if (!imageConfig.ProfileSizes.Contains(pluginConfig.ProfileSize)) if (!imageConfig.ProfileSizes.Contains(pluginConfig.ProfileSize))
{ {
pluginConfig.ProfileSize = imageConfig.ProfileSizes[^1]; pluginConfig.ProfileSize = imageConfig.ProfileSizes[^1];