From 23ba15ccfb81aac802a461341812ce21a159045f Mon Sep 17 00:00:00 2001 From: Cody Robibero Date: Sun, 27 Mar 2022 21:41:48 -0600 Subject: [PATCH] Fix StudiosImageProvider --- .../Configuration/PluginConfiguration.cs | 11 +++++++++-- .../Plugins/StudioImages/Configuration/config.html | 6 +++--- .../Plugins/StudioImages/Plugin.cs | 1 + .../Plugins/StudioImages/StudiosImageProvider.cs | 14 ++++++-------- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/MediaBrowser.Providers/Plugins/StudioImages/Configuration/PluginConfiguration.cs b/MediaBrowser.Providers/Plugins/StudioImages/Configuration/PluginConfiguration.cs index fad989ab43..cb422ef3d6 100644 --- a/MediaBrowser.Providers/Plugins/StudioImages/Configuration/PluginConfiguration.cs +++ b/MediaBrowser.Providers/Plugins/StudioImages/Configuration/PluginConfiguration.cs @@ -2,7 +2,7 @@ using MediaBrowser.Model.Plugins; -namespace MediaBrowser.Providers.Plugins.StudioImages +namespace MediaBrowser.Providers.Plugins.StudioImages.Configuration { public class PluginConfiguration : BasePluginConfiguration { @@ -12,12 +12,19 @@ namespace MediaBrowser.Providers.Plugins.StudioImages { get { + if (string.IsNullOrEmpty(_repository)) + { + _repository = Plugin.DefaultServer; + } + return _repository; } set { - _repository = value.TrimEnd('/'); + _repository = string.IsNullOrEmpty(value) + ? Plugin.DefaultServer + : value.TrimEnd('/'); } } } diff --git a/MediaBrowser.Providers/Plugins/StudioImages/Configuration/config.html b/MediaBrowser.Providers/Plugins/StudioImages/Configuration/config.html index f9fe3dc2e9..63750dbcd1 100644 --- a/MediaBrowser.Providers/Plugins/StudioImages/Configuration/config.html +++ b/MediaBrowser.Providers/Plugins/StudioImages/Configuration/config.html @@ -9,8 +9,8 @@
- -
This can be any Jellyfin-compatible artwork repository.
+ +
This can be any Jellyfin-compatible artwork repository. Leave blank to use default repository.

@@ -44,7 +44,7 @@ Dashboard.showLoadingMsg(); 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); }); diff --git a/MediaBrowser.Providers/Plugins/StudioImages/Plugin.cs b/MediaBrowser.Providers/Plugins/StudioImages/Plugin.cs index f4941565fc..5e653d039f 100644 --- a/MediaBrowser.Providers/Plugins/StudioImages/Plugin.cs +++ b/MediaBrowser.Providers/Plugins/StudioImages/Plugin.cs @@ -7,6 +7,7 @@ using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Plugins; using MediaBrowser.Model.Plugins; using MediaBrowser.Model.Serialization; +using MediaBrowser.Providers.Plugins.StudioImages.Configuration; namespace MediaBrowser.Providers.Plugins.StudioImages { diff --git a/MediaBrowser.Providers/Plugins/StudioImages/StudiosImageProvider.cs b/MediaBrowser.Providers/Plugins/StudioImages/StudiosImageProvider.cs index ce267ac848..ef822a22ad 100644 --- a/MediaBrowser.Providers/Plugins/StudioImages/StudiosImageProvider.cs +++ b/MediaBrowser.Providers/Plugins/StudioImages/StudiosImageProvider.cs @@ -18,29 +18,24 @@ using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; using MediaBrowser.Model.Providers; -using MediaBrowser.Providers.Plugins.StudioImages; -namespace MediaBrowser.Providers.Studios +namespace MediaBrowser.Providers.Plugins.StudioImages { public class StudiosImageProvider : IRemoteImageProvider { private readonly IServerConfigurationManager _config; private readonly IHttpClientFactory _httpClientFactory; private readonly IFileSystem _fileSystem; - private readonly string repositoryUrl; public StudiosImageProvider(IServerConfigurationManager config, IHttpClientFactory httpClientFactory, IFileSystem fileSystem) { _config = config; _httpClientFactory = httpClientFactory; _fileSystem = fileSystem; - repositoryUrl = Plugin.Instance.Configuration.RepositoryUrl; } public string Name => "Artwork Repository"; - public int Order => 0; - public bool Supports(BaseItem item) { return item is Studio; @@ -98,12 +93,12 @@ namespace MediaBrowser.Providers.Studios 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 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); } @@ -169,5 +164,8 @@ namespace MediaBrowser.Providers.Studios } } } + + private string GetRepositoryUrl() + => Plugin.Instance.Configuration.RepositoryUrl; } }