Merge pull request #7507 from crobibero/studio-image-plugin

Fix StudioImageProvider

(cherry picked from commit 5de2db9f52)
Signed-off-by: crobibero <cody@robibe.ro>
pull/7575/head
Cody Robibero 3 years ago committed by crobibero
parent d5cc2ad6a8
commit cec9befbed

@ -2,7 +2,7 @@
using MediaBrowser.Model.Plugins; using MediaBrowser.Model.Plugins;
namespace MediaBrowser.Providers.Plugins.StudioImages namespace MediaBrowser.Providers.Plugins.StudioImages.Configuration
{ {
public class PluginConfiguration : BasePluginConfiguration public class PluginConfiguration : BasePluginConfiguration
{ {
@ -12,12 +12,19 @@ namespace MediaBrowser.Providers.Plugins.StudioImages
{ {
get get
{ {
if (string.IsNullOrEmpty(_repository))
{
_repository = Plugin.DefaultServer;
}
return _repository; return _repository;
} }
set set
{ {
_repository = value.TrimEnd('/'); _repository = string.IsNullOrEmpty(value)
? Plugin.DefaultServer
: value.TrimEnd('/');
} }
} }
} }

@ -9,8 +9,8 @@
<div class="content-primary"> <div class="content-primary">
<form class="configForm"> <form class="configForm">
<div class="inputContainer"> <div class="inputContainer">
<input is="emby-input" type="text" id="repository" required label="Repository" /> <input is="emby-input" type="text" id="repository" label="Repository" />
<div class="fieldDescription">This can be any Jellyfin-compatible artwork repository.</div> <div class="fieldDescription">This can be any Jellyfin-compatible artwork repository. Leave blank to use default repository.</div>
</div> </div>
<br /> <br />
<div> <div>
@ -44,7 +44,7 @@
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
ApiClient.getPluginConfiguration(PluginConfig.pluginId).then(function (config) { ApiClient.getPluginConfiguration(PluginConfig.pluginId).then(function (config) {
config.RepositoryUrl = document.querySelector('#server').value; config.RepositoryUrl = document.querySelector('#repository').value;
ApiClient.updatePluginConfiguration(PluginConfig.pluginId, config).then(Dashboard.processPluginConfigurationUpdateResult); ApiClient.updatePluginConfiguration(PluginConfig.pluginId, config).then(Dashboard.processPluginConfigurationUpdateResult);
}); });

@ -7,6 +7,7 @@ using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Plugins; using MediaBrowser.Common.Plugins;
using MediaBrowser.Model.Plugins; using MediaBrowser.Model.Plugins;
using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Serialization;
using MediaBrowser.Providers.Plugins.StudioImages.Configuration;
namespace MediaBrowser.Providers.Plugins.StudioImages namespace MediaBrowser.Providers.Plugins.StudioImages
{ {

@ -18,29 +18,24 @@ using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
using MediaBrowser.Model.Providers; using MediaBrowser.Model.Providers;
using MediaBrowser.Providers.Plugins.StudioImages;
namespace MediaBrowser.Providers.Studios namespace MediaBrowser.Providers.Plugins.StudioImages
{ {
public class StudiosImageProvider : IRemoteImageProvider public class StudiosImageProvider : IRemoteImageProvider
{ {
private readonly IServerConfigurationManager _config; private readonly IServerConfigurationManager _config;
private readonly IHttpClientFactory _httpClientFactory; private readonly IHttpClientFactory _httpClientFactory;
private readonly IFileSystem _fileSystem; private readonly IFileSystem _fileSystem;
private readonly string repositoryUrl;
public StudiosImageProvider(IServerConfigurationManager config, IHttpClientFactory httpClientFactory, IFileSystem fileSystem) public StudiosImageProvider(IServerConfigurationManager config, IHttpClientFactory httpClientFactory, IFileSystem fileSystem)
{ {
_config = config; _config = config;
_httpClientFactory = httpClientFactory; _httpClientFactory = httpClientFactory;
_fileSystem = fileSystem; _fileSystem = fileSystem;
repositoryUrl = Plugin.Instance.Configuration.RepositoryUrl;
} }
public string Name => "Artwork Repository"; public string Name => "Artwork Repository";
public int Order => 0;
public bool Supports(BaseItem item) public bool Supports(BaseItem item)
{ {
return item is Studio; return item is Studio;
@ -98,12 +93,12 @@ namespace MediaBrowser.Providers.Studios
private string GetUrl(string image, string filename) private string GetUrl(string image, string filename)
{ {
return string.Format(CultureInfo.InvariantCulture, "{0}/images/{1}/{2}.jpg", repositoryUrl, image, filename); return string.Format(CultureInfo.InvariantCulture, "{0}/images/{1}/{2}.jpg", GetRepositoryUrl(), image, filename);
} }
private Task<string> EnsureThumbsList(string file, CancellationToken cancellationToken) private Task<string> EnsureThumbsList(string file, CancellationToken cancellationToken)
{ {
string url = string.Format(CultureInfo.InvariantCulture, "{0}/thumbs.txt", repositoryUrl); string url = string.Format(CultureInfo.InvariantCulture, "{0}/thumbs.txt", GetRepositoryUrl());
return EnsureList(url, file, _fileSystem, cancellationToken); return EnsureList(url, file, _fileSystem, cancellationToken);
} }
@ -169,5 +164,8 @@ namespace MediaBrowser.Providers.Studios
} }
} }
} }
private string GetRepositoryUrl()
=> Plugin.Instance.Configuration.RepositoryUrl;
} }
} }

Loading…
Cancel
Save