Merge pull request #10737 from 1337joe/tmdb-plugin-fix

Make TMDb api key configurable, fix missing/wrong image urls
This commit is contained in:
Bond-009 2023-12-28 15:48:02 +01:00 committed by GitHub
commit 919c5c26ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 6 deletions

View File

@ -75,12 +75,14 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.BoxSets
var collections = new RemoteSearchResult[collectionSearchResults.Count];
for (var i = 0; i < collectionSearchResults.Count; i++)
{
var result = collectionSearchResults[i];
var collection = new RemoteSearchResult
{
Name = collectionSearchResults[i].Name,
SearchProviderName = Name
Name = result.Name,
SearchProviderName = Name,
ImageUrl = _tmdbClientManager.GetPosterUrl(result.PosterPath)
};
collection.SetProviderId(MetadataProvider.Tmdb, collectionSearchResults[i].Id.ToString(CultureInfo.InvariantCulture));
collection.SetProviderId(MetadataProvider.Tmdb, result.Id.ToString(CultureInfo.InvariantCulture));
collections[i] = collection;
}

View File

@ -7,6 +7,12 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
/// </summary>
public class PluginConfiguration : BasePluginConfiguration
{
/// <summary>
/// Gets or sets a value to use as the API key for accessing TMDb. This is intentionally excluded from the
/// settings page as the API key should not need to be changed by most users.
/// </summary>
public string TmdbApiKey { get; set; } = string.Empty;
/// <summary>
/// Gets or sets a value indicating whether include adult content when searching with TMDb.
/// </summary>

View File

@ -64,9 +64,18 @@
var clientConfig, pluginConfig;
var configureImageScaling = function() {
if (clientConfig === null || pluginConfig === null) {
if (clientConfig === undefined || pluginConfig === undefined) {
return;
}
if (Object.keys(clientConfig).length === 0) {
clientConfig = {
PosterSizes: [pluginConfig.PosterSize],
BackdropSizes: [pluginConfig.BackdropSize],
LogoSizes: [pluginConfig.LogoSize],
ProfileSizes: [pluginConfig.ProfileSize],
StillSizes: [pluginConfig.StillSize]
};
}
var sizeOptionsGenerator = function (size) {
return '<option value="' + size + '">' + size + '</option>';
@ -104,6 +113,15 @@
ApiClient.fetch(request).then(function (config) {
clientConfig = config;
configureImageScaling();
}, function (error) {
error.text().then(function (contents) {
Dashboard.alert({
title: error.statusText,
message: contents
});
clientConfig = {};
configureImageScaling();
});
});
ApiClient.getPluginConfiguration(PluginConfig.pluginId).then(function (config) {

View File

@ -299,7 +299,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
if (!string.IsNullOrWhiteSpace(person.ProfilePath))
{
personInfo.ImageUrl = _tmdbClientManager.GetPosterUrl(person.ProfilePath);
personInfo.ImageUrl = _tmdbClientManager.GetProfileUrl(person.ProfilePath);
}
if (person.Id > 0)

View File

@ -36,7 +36,11 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
public TmdbClientManager(IMemoryCache memoryCache)
{
_memoryCache = memoryCache;
_tmDbClient = new TMDbClient(TmdbUtils.ApiKey);
var apiKey = Plugin.Instance.Configuration.TmdbApiKey;
apiKey = string.IsNullOrEmpty(apiKey) ? TmdbUtils.ApiKey : apiKey;
_tmDbClient = new TMDbClient(apiKey);
// Not really interested in NotFoundException
_tmDbClient.ThrowApiExceptions = false;
}