From 7986465cf785ca385fd1765326887e550bced033 Mon Sep 17 00:00:00 2001 From: Greenback Date: Sun, 6 Dec 2020 23:48:54 +0000 Subject: Initial upload --- MediaBrowser.Common/Plugins/LocalPlugin.cs | 94 +++++++++++++++++++----------- 1 file changed, 61 insertions(+), 33 deletions(-) (limited to 'MediaBrowser.Common/Plugins/LocalPlugin.cs') diff --git a/MediaBrowser.Common/Plugins/LocalPlugin.cs b/MediaBrowser.Common/Plugins/LocalPlugin.cs index c97e75a3b..ef9ab7a7d 100644 --- a/MediaBrowser.Common/Plugins/LocalPlugin.cs +++ b/MediaBrowser.Common/Plugins/LocalPlugin.cs @@ -1,6 +1,9 @@ +#nullable enable using System; using System.Collections.Generic; using System.Globalization; +using System.Reflection; +using MediaBrowser.Model.Plugins; namespace MediaBrowser.Common.Plugins { @@ -9,36 +12,48 @@ namespace MediaBrowser.Common.Plugins /// public class LocalPlugin : IEquatable { + private readonly bool _supported; + private Version? _version; + /// /// Initializes a new instance of the class. /// - /// The plugin id. - /// The plugin name. - /// The plugin version. /// The plugin path. - public LocalPlugin(Guid id, string name, Version version, string path) + /// True if Jellyfin supports this version of the plugin. + /// The manifest record for this plugin, or null if one does not exist. + public LocalPlugin(string path, bool isSupported, PluginManifest manifest) { - Id = id; - Name = name; - Version = version; Path = path; DllFiles = new List(); + _supported = isSupported; + Manifest = manifest; } /// /// Gets the plugin id. /// - public Guid Id { get; } + public Guid Id => Manifest.Guid; /// /// Gets the plugin name. /// - public string Name { get; } + public string Name => Manifest.Name; /// /// Gets the plugin version. /// - public Version Version { get; } + public Version Version + { + get + { + if (_version == null) + { + _version = Version.Parse(Manifest.Version); + } + + return _version; + } + } /// /// Gets the plugin path. @@ -51,26 +66,24 @@ namespace MediaBrowser.Common.Plugins public List DllFiles { get; } /// - /// == operator. + /// Gets or sets the instance of this plugin. /// - /// Left item. - /// Right item. - /// Comparison result. - public static bool operator ==(LocalPlugin left, LocalPlugin right) - { - return left.Equals(right); - } + public IPlugin? Instance { get; set; } /// - /// != operator. + /// Gets a value indicating whether Jellyfin supports this version of the plugin, and it's enabled. /// - /// Left item. - /// Right item. - /// Comparison result. - public static bool operator !=(LocalPlugin left, LocalPlugin right) - { - return !left.Equals(right); - } + public bool IsEnabledAndSupported => _supported && Manifest.Status >= PluginStatus.Active; + + /// + /// Gets a value indicating whether the plugin has a manifest. + /// + public PluginManifest Manifest { get; } + + /// + /// Gets or sets a value indicating the assembly of the plugin. + /// + public Assembly? Assembly { get; set; } /// /// Compare two . @@ -80,10 +93,15 @@ namespace MediaBrowser.Common.Plugins /// Comparison result. public static int Compare(LocalPlugin a, LocalPlugin b) { + if (a == null || b == null) + { + throw new ArgumentNullException(a == null ? nameof(a) : nameof(b)); + } + var compare = string.Compare(a.Name, b.Name, true, CultureInfo.InvariantCulture); // Id is not equal but name is. - if (a.Id != b.Id && compare == 0) + if (!a.Id.Equals(b.Id) && compare == 0) { compare = a.Id.CompareTo(b.Id); } @@ -91,8 +109,20 @@ namespace MediaBrowser.Common.Plugins return compare == 0 ? a.Version.CompareTo(b.Version) : compare; } + /// + /// Returns the plugin information. + /// + /// A instance containing the information. + public PluginInfo GetPluginInfo() + { + var inst = Instance?.GetPluginInfo() ?? new PluginInfo(Manifest.Name, Version, Manifest.Description, Manifest.Guid, true); + inst.Status = Manifest.Status; + inst.HasImage = !string.IsNullOrEmpty(Manifest.ImageUrl); + return inst; + } + /// - public override bool Equals(object obj) + public override bool Equals(object? obj) { return obj is LocalPlugin other && this.Equals(other); } @@ -104,16 +134,14 @@ namespace MediaBrowser.Common.Plugins } /// - public bool Equals(LocalPlugin other) + public bool Equals(LocalPlugin? other) { - // Do not use == or != for comparison as this class overrides the operators. - if (object.ReferenceEquals(other, null)) + if (other == null) { return false; } - return Name.Equals(other.Name, StringComparison.OrdinalIgnoreCase) - && Id.Equals(other.Id); + return Name.Equals(other.Name, StringComparison.OrdinalIgnoreCase) && Id.Equals(other.Id) && Version.Equals(other.Version); } } } -- cgit v1.2.3 From eb2439f23b05a9b92a81ee96c7801d10ccfbb25d Mon Sep 17 00:00:00 2001 From: Greenback Date: Tue, 15 Dec 2020 16:37:11 +0000 Subject: Changes as recommended. --- Emby.Server.Implementations/ApplicationHost.cs | 2 +- .../Plugins/PluginManager.cs | 59 +++++++++------------- .../Updates/InstallationManager.cs | 15 +----- Jellyfin.Api/Controllers/PackageController.cs | 2 - MediaBrowser.Common/Plugins/LocalPlugin.cs | 5 -- MediaBrowser.Model/Updates/PackageInfo.cs | 9 ++++ 6 files changed, 35 insertions(+), 57 deletions(-) (limited to 'MediaBrowser.Common/Plugins/LocalPlugin.cs') diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 17cccdaf9..216cb5e75 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -396,7 +396,7 @@ namespace Emby.Server.Implementations Logger.LogError("DI Loop detected in the attempted creation of {Type}", type.FullName); foreach (var entry in _creatingInstances) { - Logger.LogError("Called from: {stack}", entry.FullName); + Logger.LogError("Called from: {TypeName}", entry.FullName); } _pluginManager.FailPlugin(type.Assembly); diff --git a/Emby.Server.Implementations/Plugins/PluginManager.cs b/Emby.Server.Implementations/Plugins/PluginManager.cs index 010d2829c..944b74652 100644 --- a/Emby.Server.Implementations/Plugins/PluginManager.cs +++ b/Emby.Server.Implementations/Plugins/PluginManager.cs @@ -96,9 +96,10 @@ namespace Emby.Server.Implementations foreach (var file in plugin.DllFiles) { + Assembly assembly; try { - plugin.Assembly = Assembly.LoadFrom(file); + assembly = Assembly.LoadFrom(file); } catch (FileLoadException ex) { @@ -107,8 +108,8 @@ namespace Emby.Server.Implementations continue; } - _logger.LogInformation("Loaded assembly {Assembly} from {Path}", plugin.Assembly.FullName, file); - yield return plugin.Assembly; + _logger.LogInformation("Loaded assembly {Assembly} from {Path}", assembly.FullName, file); + yield return assembly; } } } @@ -203,6 +204,7 @@ namespace Emby.Server.Implementations return true; } + _logger.LogWarning("Unable to delete {Path}, so marking as deleteOnStartup.", plugin.Path); // Unable to delete, so disable. return ChangePluginState(plugin, PluginStatus.DeleteOnStartup); } @@ -310,10 +312,7 @@ namespace Emby.Server.Implementations throw new ArgumentNullException(nameof(assembly)); } - var plugin = _plugins.Where( - p => assembly.Equals(p.Assembly) - || string.Equals(assembly.Location, assembly.Location, StringComparison.OrdinalIgnoreCase)) - .FirstOrDefault(); + var plugin = _plugins.Where(p => p.DllFiles.Contains(assembly.Location)).FirstOrDefault(); if (plugin == null) { // A plugin's assembly didn't cause this issue, so ignore it. @@ -366,20 +365,7 @@ namespace Emby.Server.Implementations } plugin.Manifest.Status = state; - SaveManifest(plugin.Manifest, plugin.Path); - try - { - var data = JsonSerializer.Serialize(plugin.Manifest, _jsonOptions); - File.WriteAllText(Path.Combine(plugin.Path, "meta.json"), data, Encoding.UTF8); - return true; - } -#pragma warning disable CA1031 // Do not catch general exception types - catch (Exception e) -#pragma warning restore CA1031 // Do not catch general exception types - { - _logger.LogWarning(e, "Unable to disable plugin {Path}", plugin.Path); - return false; - } + return SaveManifest(plugin.Manifest, plugin.Path); } /// @@ -509,15 +495,14 @@ namespace Emby.Server.Implementations // Attempt a cleanup of old folders. try { - _logger.LogDebug("Deleting {Path}", plugin.Path); Directory.Delete(plugin.Path, true); + _logger.LogDebug("Deleted {Path}", plugin.Path); _plugins.Remove(plugin); } #pragma warning disable CA1031 // Do not catch general exception types - catch (Exception e) + catch #pragma warning restore CA1031 // Do not catch general exception types { - _logger.LogWarning(e, "Unable to delete {Path}", plugin.Path); return false; } @@ -670,21 +655,23 @@ namespace Emby.Server.Implementations _logger.LogWarning(e, "Unable to delete {Path}", path); } - versions.RemoveAt(x); - } - - if (!cleaned) - { - if (manifest == null) + if (cleaned) { - _logger.LogWarning("Unable to disable plugin {Path}", entry.Path); - continue; + versions.RemoveAt(x); } - - if (manifest.Status != PluginStatus.DeleteOnStartup) + else { - manifest.Status = PluginStatus.DeleteOnStartup; - SaveManifest(manifest, entry.Path); + if (manifest == null) + { + _logger.LogWarning("Unable to disable plugin {Path}", entry.Path); + continue; + } + + if (manifest.Status != PluginStatus.DeleteOnStartup) + { + manifest.Status = PluginStatus.DeleteOnStartup; + SaveManifest(manifest, entry.Path); + } } } } diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index b7bbbd348..fc80bdd75 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -8,7 +8,6 @@ using System.Linq; using System.Net.Http; using System.Net.Http.Json; using System.Security.Cryptography; -using System.Text; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -106,18 +105,8 @@ namespace Emby.Server.Implementations.Updates try { List? packages; - var uri = new Uri(manifest); - if (uri.Scheme.StartsWith("http", StringComparison.OrdinalIgnoreCase)) - { - packages = await _httpClientFactory.CreateClient(NamedClient.Default) - .GetFromJsonAsync>(uri, _jsonSerializerOptions, cancellationToken).ConfigureAwait(false); - } - else - { - // Local Packages - var data = File.ReadAllText(manifest, Encoding.UTF8); - packages = JsonSerializer.Deserialize>(data, _jsonSerializerOptions); - } + packages = await _httpClientFactory.CreateClient(NamedClient.Default) + .GetFromJsonAsync>(new Uri(manifest), _jsonSerializerOptions, cancellationToken).ConfigureAwait(false); if (packages == null) { diff --git a/Jellyfin.Api/Controllers/PackageController.cs b/Jellyfin.Api/Controllers/PackageController.cs index 906188026..9ab8e0bdc 100644 --- a/Jellyfin.Api/Controllers/PackageController.cs +++ b/Jellyfin.Api/Controllers/PackageController.cs @@ -44,7 +44,6 @@ namespace Jellyfin.Api.Controllers /// A containing package information. [HttpGet("Packages/{name}")] [ProducesResponseType(StatusCodes.Status200OK)] - [Produces(JsonDefaults.CamelCaseMediaType)] public async Task> GetPackageInfo( [FromRoute, Required] string name, [FromQuery] Guid? assemblyGuid) @@ -71,7 +70,6 @@ namespace Jellyfin.Api.Controllers /// An containing available packages information. [HttpGet("Packages")] [ProducesResponseType(StatusCodes.Status200OK)] - [Produces(JsonDefaults.CamelCaseMediaType)] public async Task> GetPackages() { IEnumerable packages = await _installationManager.GetAvailablePackages().ConfigureAwait(false); diff --git a/MediaBrowser.Common/Plugins/LocalPlugin.cs b/MediaBrowser.Common/Plugins/LocalPlugin.cs index ef9ab7a7d..e48ebbfa5 100644 --- a/MediaBrowser.Common/Plugins/LocalPlugin.cs +++ b/MediaBrowser.Common/Plugins/LocalPlugin.cs @@ -80,11 +80,6 @@ namespace MediaBrowser.Common.Plugins /// public PluginManifest Manifest { get; } - /// - /// Gets or sets a value indicating the assembly of the plugin. - /// - public Assembly? Assembly { get; set; } - /// /// Compare two . /// diff --git a/MediaBrowser.Model/Updates/PackageInfo.cs b/MediaBrowser.Model/Updates/PackageInfo.cs index 77e2d8d88..63fd71742 100644 --- a/MediaBrowser.Model/Updates/PackageInfo.cs +++ b/MediaBrowser.Model/Updates/PackageInfo.cs @@ -1,6 +1,7 @@ #nullable enable using System; using System.Collections.Generic; +using System.Text.Json.Serialization; namespace MediaBrowser.Model.Updates { @@ -27,30 +28,35 @@ namespace MediaBrowser.Model.Updates /// Gets or sets the name. /// /// The name. + [JsonPropertyName("name")] public string Name { get; set; } /// /// Gets or sets a long description of the plugin containing features or helpful explanations. /// /// The description. + /// [JsonPropertyName("description")] public string Description { get; set; } /// /// Gets or sets a short overview of what the plugin does. /// /// The overview. + [JsonPropertyName("overview")] public string Overview { get; set; } /// /// Gets or sets the owner. /// /// The owner. + [JsonPropertyName("owner")] public string Owner { get; set; } /// /// Gets or sets the category. /// /// The category. + [JsonPropertyName("category")] public string Category { get; set; } /// @@ -58,6 +64,7 @@ namespace MediaBrowser.Model.Updates /// This is used to identify the proper item for automatic updates. /// /// The name. + [JsonPropertyName("guid")] #pragma warning disable CA1720 // Identifier contains type name public string Guid { get; set; } #pragma warning restore CA1720 // Identifier contains type name @@ -66,6 +73,7 @@ namespace MediaBrowser.Model.Updates /// Gets or sets the versions. /// /// The versions. + [JsonPropertyName("versions")] #pragma warning disable CA2227 // Collection properties should be read only public IList Versions { get; set; } #pragma warning restore CA2227 // Collection properties should be read only @@ -73,6 +81,7 @@ namespace MediaBrowser.Model.Updates /// /// Gets or sets the image url for the package. /// + [JsonPropertyName("imageUrl")] public string? ImageUrl { get; set; } } } -- cgit v1.2.3 From 6d3e1d6b5726201d7c943ba007ef873810ffd7bc Mon Sep 17 00:00:00 2001 From: Greenback Date: Wed, 16 Dec 2020 19:37:23 +0000 Subject: Small Optimization --- MediaBrowser.Common/Plugins/LocalPlugin.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MediaBrowser.Common/Plugins/LocalPlugin.cs') diff --git a/MediaBrowser.Common/Plugins/LocalPlugin.cs b/MediaBrowser.Common/Plugins/LocalPlugin.cs index e48ebbfa5..8aded8b9b 100644 --- a/MediaBrowser.Common/Plugins/LocalPlugin.cs +++ b/MediaBrowser.Common/Plugins/LocalPlugin.cs @@ -93,7 +93,7 @@ namespace MediaBrowser.Common.Plugins throw new ArgumentNullException(a == null ? nameof(a) : nameof(b)); } - var compare = string.Compare(a.Name, b.Name, true, CultureInfo.InvariantCulture); + var compare = string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase); // Id is not equal but name is. if (!a.Id.Equals(b.Id) && compare == 0) -- cgit v1.2.3 From ce19f2be55c7484488bebfd29bd42c1f082ae888 Mon Sep 17 00:00:00 2001 From: Greenback Date: Fri, 18 Dec 2020 20:37:35 +0000 Subject: Renamed Guid property to Id --- .../Plugins/PluginManager.cs | 4 +-- .../Updates/InstallationManager.cs | 12 ++++---- MediaBrowser.Common/Plugins/BasePluginOfT.cs | 17 +++++++++-- MediaBrowser.Common/Plugins/LocalPlugin.cs | 6 ++-- MediaBrowser.Common/Plugins/PluginManifest.cs | 6 ++-- MediaBrowser.Model/Plugins/PluginPageInfo.cs | 34 +++++++++++++++++----- MediaBrowser.Model/Updates/InstallationInfo.cs | 8 +++-- MediaBrowser.Model/Updates/PackageInfo.cs | 6 ++-- MediaBrowser.Providers/Plugins/AudioDb/Plugin.cs | 2 +- .../Plugins/MusicBrainz/Plugin.cs | 2 +- MediaBrowser.Providers/Plugins/Omdb/Plugin.cs | 2 +- 11 files changed, 65 insertions(+), 34 deletions(-) (limited to 'MediaBrowser.Common/Plugins/LocalPlugin.cs') diff --git a/Emby.Server.Implementations/Plugins/PluginManager.cs b/Emby.Server.Implementations/Plugins/PluginManager.cs index 4c508279c..613e610d3 100644 --- a/Emby.Server.Implementations/Plugins/PluginManager.cs +++ b/Emby.Server.Implementations/Plugins/PluginManager.cs @@ -376,7 +376,7 @@ namespace Emby.Server.Implementations.Plugins true, new PluginManifest { - Guid = instance.Id, + Id = instance.Id, Status = PluginStatus.Active, Name = instance.Name, Version = instance.Version.ToString() @@ -537,7 +537,7 @@ namespace Emby.Server.Implementations.Plugins Status = PluginStatus.Restart, Name = metafile, AutoUpdate = false, - Guid = metafile.GetMD5(), + Id = metafile.GetMD5(), TargetAbi = _appVersion.ToString(), Version = version.ToString() }; diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index cf059fb97..267a33875 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -178,7 +178,7 @@ namespace Emby.Server.Implementations.Updates // Where repositories have the same content, the details from the first is taken. foreach (var package in await GetPackages(repository.Name ?? "Unnamed Repo", repository.Url, true, cancellationToken).ConfigureAwait(true)) { - if (!Guid.TryParse(package.Guid, out var packageGuid)) + if (!Guid.TryParse(package.Id, out var packageGuid)) { // Package doesn't have a valid GUID, skip. continue; @@ -245,7 +245,7 @@ namespace Emby.Server.Implementations.Updates if (guid != Guid.Empty) { - availablePackages = availablePackages.Where(x => Guid.Parse(x.Guid) == guid); + availablePackages = availablePackages.Where(x => Guid.Parse(x.Id) == guid); } if (specificVersion != null) @@ -290,7 +290,7 @@ namespace Emby.Server.Implementations.Updates yield return new InstallationInfo { Changelog = v.Changelog, - Guid = new Guid(package.Guid), + Id = new Guid(package.Id), Name = package.Name, Version = v.VersionNumber, SourceUrl = v.SourceUrl, @@ -414,7 +414,7 @@ namespace Emby.Server.Implementations.Updates { lock (_currentInstallationsLock) { - var install = _currentInstallations.Find(x => x.info.Guid == id); + var install = _currentInstallations.Find(x => x.info.Id == id); if (install == default((InstallationInfo, CancellationTokenSource))) { return false; @@ -512,7 +512,7 @@ namespace Emby.Server.Implementations.Updates var compatibleVersions = GetCompatibleVersions(pluginCatalog, plugin.Name, plugin.Id, minVersion: plugin.Version); var version = compatibleVersions.FirstOrDefault(y => y.Version > plugin.Version); - if (version != null && CompletedInstallations.All(x => x.Guid != version.Guid)) + if (version != null && CompletedInstallations.All(x => x.Id != version.Id)) { yield return version; } @@ -577,7 +577,7 @@ namespace Emby.Server.Implementations.Updates private async Task InstallPackageInternal(InstallationInfo package, CancellationToken cancellationToken) { // Set last update time if we were installed before - LocalPlugin? plugin = _pluginManager.Plugins.FirstOrDefault(p => p.Id.Equals(package.Guid) && p.Version.Equals(package.Version)) + LocalPlugin? plugin = _pluginManager.Plugins.FirstOrDefault(p => p.Id.Equals(package.Id) && p.Version.Equals(package.Version)) ?? _pluginManager.Plugins.FirstOrDefault(p => p.Name.Equals(package.Name, StringComparison.OrdinalIgnoreCase) && p.Version.Equals(package.Version)); if (plugin != null) { diff --git a/MediaBrowser.Common/Plugins/BasePluginOfT.cs b/MediaBrowser.Common/Plugins/BasePluginOfT.cs index 66aec92ab..e4e766472 100644 --- a/MediaBrowser.Common/Plugins/BasePluginOfT.cs +++ b/MediaBrowser.Common/Plugins/BasePluginOfT.cs @@ -48,7 +48,7 @@ namespace MediaBrowser.Common.Plugins var assemblyFilePath = assembly.Location; var dataFolderPath = Path.Combine(ApplicationPaths.PluginsPath, Path.GetFileNameWithoutExtension(assemblyFilePath)); - if (!Directory.Exists(dataFolderPath)) + if (!Directory.Exists(dataFolderPath) && Version != null) { // Try again with the version number appended to the folder name. dataFolderPath = dataFolderPath + "_" + Version.ToString(); @@ -137,7 +137,20 @@ namespace MediaBrowser.Common.Plugins /// Gets the full path to the configuration file. /// /// The configuration file path. - public string ConfigurationFilePath { get; } + public string ConfigurationFilePath + { + get + { + var dataFolderPath = Path.Combine(ApplicationPaths.PluginsPath, Path.GetFileNameWithoutExtension(AssemblyFilePath)); + if (!Directory.Exists(dataFolderPath) && Version != null) + { + // Try again with the version number appended to the folder name. + return dataFolderPath + "_" + Version.ToString(); + } + + return dataFolderPath; + } + } /// /// Gets the plugin configuration. diff --git a/MediaBrowser.Common/Plugins/LocalPlugin.cs b/MediaBrowser.Common/Plugins/LocalPlugin.cs index 8aded8b9b..40ecb0a67 100644 --- a/MediaBrowser.Common/Plugins/LocalPlugin.cs +++ b/MediaBrowser.Common/Plugins/LocalPlugin.cs @@ -1,8 +1,6 @@ #nullable enable using System; using System.Collections.Generic; -using System.Globalization; -using System.Reflection; using MediaBrowser.Model.Plugins; namespace MediaBrowser.Common.Plugins @@ -32,7 +30,7 @@ namespace MediaBrowser.Common.Plugins /// /// Gets the plugin id. /// - public Guid Id => Manifest.Guid; + public Guid Id => Manifest.Id; /// /// Gets the plugin name. @@ -110,7 +108,7 @@ namespace MediaBrowser.Common.Plugins /// A instance containing the information. public PluginInfo GetPluginInfo() { - var inst = Instance?.GetPluginInfo() ?? new PluginInfo(Manifest.Name, Version, Manifest.Description, Manifest.Guid, true); + var inst = Instance?.GetPluginInfo() ?? new PluginInfo(Manifest.Name, Version, Manifest.Description, Manifest.Id, true); inst.Status = Manifest.Status; inst.HasImage = !string.IsNullOrEmpty(Manifest.ImageUrl); return inst; diff --git a/MediaBrowser.Common/Plugins/PluginManifest.cs b/MediaBrowser.Common/Plugins/PluginManifest.cs index 1bd17933c..39ee450a6 100644 --- a/MediaBrowser.Common/Plugins/PluginManifest.cs +++ b/MediaBrowser.Common/Plugins/PluginManifest.cs @@ -1,5 +1,6 @@ #nullable enable using System; +using System.Text.Json.Serialization; using MediaBrowser.Model.Plugins; namespace MediaBrowser.Common.Plugins @@ -27,9 +28,8 @@ namespace MediaBrowser.Common.Plugins /// /// Gets or sets the Global Unique Identifier for the plugin. /// -#pragma warning disable CA1720 // Identifier contains type name - public Guid Guid { get; set; } -#pragma warning restore CA1720 // Identifier contains type name + [JsonPropertyName("Guid")] + public Guid Id { get; set; } /// /// Gets or sets the Name of the plugin. diff --git a/MediaBrowser.Model/Plugins/PluginPageInfo.cs b/MediaBrowser.Model/Plugins/PluginPageInfo.cs index ca72e19ee..85c0aa204 100644 --- a/MediaBrowser.Model/Plugins/PluginPageInfo.cs +++ b/MediaBrowser.Model/Plugins/PluginPageInfo.cs @@ -1,20 +1,40 @@ -#nullable disable -#pragma warning disable CS1591 +#nullable enable namespace MediaBrowser.Model.Plugins { + /// + /// Defines the . + /// public class PluginPageInfo { - public string Name { get; set; } + /// + /// Gets or sets the name. + /// + public string Name { get; set; } = string.Empty; - public string DisplayName { get; set; } + /// + /// Gets or sets the display name. + /// + public string? DisplayName { get; set; } - public string EmbeddedResourcePath { get; set; } + /// + /// Gets or sets the resource path. + /// + public string EmbeddedResourcePath { get; set; } = string.Empty; + /// + /// Gets or sets a value indicating whether this plugin should appear in the main menu. + /// public bool EnableInMainMenu { get; set; } - public string MenuSection { get; set; } + /// + /// Gets or sets the menu section. + /// + public string? MenuSection { get; set; } - public string MenuIcon { get; set; } + /// + /// Gets or sets the menu icon. + /// + public string? MenuIcon { get; set; } } } diff --git a/MediaBrowser.Model/Updates/InstallationInfo.cs b/MediaBrowser.Model/Updates/InstallationInfo.cs index a6d80dba6..eebe1a903 100644 --- a/MediaBrowser.Model/Updates/InstallationInfo.cs +++ b/MediaBrowser.Model/Updates/InstallationInfo.cs @@ -1,5 +1,6 @@ #nullable disable using System; +using System.Text.Json.Serialization; namespace MediaBrowser.Model.Updates { @@ -9,10 +10,11 @@ namespace MediaBrowser.Model.Updates public class InstallationInfo { /// - /// Gets or sets the guid. + /// Gets or sets the Id. /// - /// The guid. - public Guid Guid { get; set; } + /// The Id. + [JsonPropertyName("Guid")] + public Guid Id { get; set; } /// /// Gets or sets the name. diff --git a/MediaBrowser.Model/Updates/PackageInfo.cs b/MediaBrowser.Model/Updates/PackageInfo.cs index 63fd71742..2d05ed636 100644 --- a/MediaBrowser.Model/Updates/PackageInfo.cs +++ b/MediaBrowser.Model/Updates/PackageInfo.cs @@ -16,7 +16,7 @@ namespace MediaBrowser.Model.Updates public PackageInfo() { Versions = Array.Empty(); - Guid = string.Empty; + Id = string.Empty; Category = string.Empty; Name = string.Empty; Overview = string.Empty; @@ -65,9 +65,7 @@ namespace MediaBrowser.Model.Updates /// /// The name. [JsonPropertyName("guid")] -#pragma warning disable CA1720 // Identifier contains type name - public string Guid { get; set; } -#pragma warning restore CA1720 // Identifier contains type name + public string Id { get; set; } /// /// Gets or sets the versions. diff --git a/MediaBrowser.Providers/Plugins/AudioDb/Plugin.cs b/MediaBrowser.Providers/Plugins/AudioDb/Plugin.cs index b5bd72ff0..ba0d7b569 100644 --- a/MediaBrowser.Providers/Plugins/AudioDb/Plugin.cs +++ b/MediaBrowser.Providers/Plugins/AudioDb/Plugin.cs @@ -1,4 +1,4 @@ -#pragma warning disable CS1591 +#pragma warning disable CS1591 using System; using System.Collections.Generic; diff --git a/MediaBrowser.Providers/Plugins/MusicBrainz/Plugin.cs b/MediaBrowser.Providers/Plugins/MusicBrainz/Plugin.cs index 90266e440..43bd3a472 100644 --- a/MediaBrowser.Providers/Plugins/MusicBrainz/Plugin.cs +++ b/MediaBrowser.Providers/Plugins/MusicBrainz/Plugin.cs @@ -1,4 +1,4 @@ -#pragma warning disable CS1591 +#pragma warning disable CS1591 using System; using System.Collections.Generic; diff --git a/MediaBrowser.Providers/Plugins/Omdb/Plugin.cs b/MediaBrowser.Providers/Plugins/Omdb/Plugin.cs index 41ca56164..d7f6781e5 100644 --- a/MediaBrowser.Providers/Plugins/Omdb/Plugin.cs +++ b/MediaBrowser.Providers/Plugins/Omdb/Plugin.cs @@ -1,4 +1,4 @@ -#pragma warning disable CS1591 +#pragma warning disable CS1591 using System; using System.Collections.Generic; -- cgit v1.2.3 From 5d748c0e9f1ad87bece090934c5da6c4edacb8f7 Mon Sep 17 00:00:00 2001 From: Greenback Date: Fri, 18 Dec 2020 20:52:44 +0000 Subject: Renamed to ImagePath --- Jellyfin.Api/Controllers/PluginsController.cs | 10 +++++----- MediaBrowser.Common/Plugins/LocalPlugin.cs | 2 +- MediaBrowser.Common/Plugins/PluginManifest.cs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'MediaBrowser.Common/Plugins/LocalPlugin.cs') diff --git a/Jellyfin.Api/Controllers/PluginsController.cs b/Jellyfin.Api/Controllers/PluginsController.cs index 1365764fb..365bb2248 100644 --- a/Jellyfin.Api/Controllers/PluginsController.cs +++ b/Jellyfin.Api/Controllers/PluginsController.cs @@ -303,16 +303,16 @@ namespace Jellyfin.Api.Controllers return NotFound(); } - var imgPath = Path.Combine(plugin.Path, plugin.Manifest.ImageUrl ?? string.Empty); + var imagePath = Path.Combine(plugin.Path, plugin.Manifest.ImagePath ?? string.Empty); if (((ServerConfiguration)_config.CommonConfiguration).DisablePluginImages - || plugin.Manifest.ImageUrl == null - || !System.IO.File.Exists(imgPath)) + || plugin.Manifest.ImagePath == null + || !System.IO.File.Exists(imagePath)) { return NotFound(); } - imgPath = Path.Combine(plugin.Path, plugin.Manifest.ImageUrl); - return PhysicalFile(imgPath, MimeTypes.GetMimeType(imgPath)); + imagePath = Path.Combine(plugin.Path, plugin.Manifest.ImagePath); + return PhysicalFile(imagePath, MimeTypes.GetMimeType(imagePath)); } /// diff --git a/MediaBrowser.Common/Plugins/LocalPlugin.cs b/MediaBrowser.Common/Plugins/LocalPlugin.cs index 40ecb0a67..23b6cfa81 100644 --- a/MediaBrowser.Common/Plugins/LocalPlugin.cs +++ b/MediaBrowser.Common/Plugins/LocalPlugin.cs @@ -110,7 +110,7 @@ namespace MediaBrowser.Common.Plugins { var inst = Instance?.GetPluginInfo() ?? new PluginInfo(Manifest.Name, Version, Manifest.Description, Manifest.Id, true); inst.Status = Manifest.Status; - inst.HasImage = !string.IsNullOrEmpty(Manifest.ImageUrl); + inst.HasImage = !string.IsNullOrEmpty(Manifest.ImagePath); return inst; } diff --git a/MediaBrowser.Common/Plugins/PluginManifest.cs b/MediaBrowser.Common/Plugins/PluginManifest.cs index 39ee450a6..755ccafda 100644 --- a/MediaBrowser.Common/Plugins/PluginManifest.cs +++ b/MediaBrowser.Common/Plugins/PluginManifest.cs @@ -80,6 +80,6 @@ namespace MediaBrowser.Common.Plugins /// Gets or sets a value indicating whether this plugin has an image. /// Image must be located in the local plugin folder. /// - public string? ImageUrl { get; set; } + public string? ImagePath { get; set; } } } -- cgit v1.2.3