aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordkanada <dkanada@users.noreply.github.com>2020-06-04 23:57:57 +0900
committerdkanada <dkanada@users.noreply.github.com>2020-06-04 23:57:57 +0900
commitb7f4b8e2b5a61e3784b3e5dc68c1123bddbff264 (patch)
tree52973ae8430ceeb62bb877a0fd6680d518d3b6b8
parent836741f2aa6d2140051a50f746602e4b8c63a231 (diff)
initial implementation for custom plugin repositories
-rw-r--r--Emby.Server.Implementations/ConfigurationOptions.cs1
-rw-r--r--Emby.Server.Implementations/IStartupOptions.cs5
-rw-r--r--Emby.Server.Implementations/Updates/InstallationManager.cs39
-rw-r--r--Jellyfin.Server/StartupOptions.cs9
-rw-r--r--MediaBrowser.Api/Devices/DeviceService.cs1
-rw-r--r--MediaBrowser.Api/PackageService.cs25
-rw-r--r--MediaBrowser.Common/Updates/IInstallationManager.cs8
-rw-r--r--MediaBrowser.Model/Configuration/ServerConfiguration.cs18
-rw-r--r--MediaBrowser.Model/Updates/RepositoryInfo.cs34
9 files changed, 106 insertions, 34 deletions
diff --git a/Emby.Server.Implementations/ConfigurationOptions.cs b/Emby.Server.Implementations/ConfigurationOptions.cs
index dea9b6682..ff7ee085f 100644
--- a/Emby.Server.Implementations/ConfigurationOptions.cs
+++ b/Emby.Server.Implementations/ConfigurationOptions.cs
@@ -17,7 +17,6 @@ namespace Emby.Server.Implementations
{
{ HostWebClientKey, bool.TrueString },
{ HttpListenerHost.DefaultRedirectKey, "web/index.html" },
- { InstallationManager.PluginManifestUrlKey, "https://repo.jellyfin.org/releases/plugin/manifest-stable.json" },
{ FfmpegProbeSizeKey, "1G" },
{ FfmpegAnalyzeDurationKey, "200M" },
{ PlaylistsAllowDuplicatesKey, bool.TrueString }
diff --git a/Emby.Server.Implementations/IStartupOptions.cs b/Emby.Server.Implementations/IStartupOptions.cs
index 0b9f80538..e7e72c686 100644
--- a/Emby.Server.Implementations/IStartupOptions.cs
+++ b/Emby.Server.Implementations/IStartupOptions.cs
@@ -37,11 +37,6 @@ namespace Emby.Server.Implementations
string RestartArgs { get; }
/// <summary>
- /// Gets the value of the --plugin-manifest-url command line option.
- /// </summary>
- string PluginManifestUrl { get; }
-
- /// <summary>
/// Gets the value of the --published-server-url command line option.
/// </summary>
Uri PublishedServerUrl { get; }
diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs
index 178f32c31..bdd7c31d6 100644
--- a/Emby.Server.Implementations/Updates/InstallationManager.cs
+++ b/Emby.Server.Implementations/Updates/InstallationManager.cs
@@ -32,11 +32,6 @@ namespace Emby.Server.Implementations.Updates
public class InstallationManager : IInstallationManager
{
/// <summary>
- /// The key for a setting that specifies a URL for the plugin repository JSON manifest.
- /// </summary>
- public const string PluginManifestUrlKey = "InstallationManager:PluginManifestUrl";
-
- /// <summary>
/// The logger.
/// </summary>
private readonly ILogger _logger;
@@ -122,16 +117,14 @@ namespace Emby.Server.Implementations.Updates
public IEnumerable<InstallationInfo> CompletedInstallations => _completedInstallationsInternal;
/// <inheritdoc />
- public async Task<IReadOnlyList<PackageInfo>> GetAvailablePackages(CancellationToken cancellationToken = default)
+ public async Task<IEnumerable<PackageInfo>> GetPackages(string manifest, CancellationToken cancellationToken = default)
{
- var manifestUrl = _appConfig.GetValue<string>(PluginManifestUrlKey);
-
try
{
using (var response = await _httpClient.SendAsync(
new HttpRequestOptions
{
- Url = manifestUrl,
+ Url = manifest,
CancellationToken = cancellationToken,
CacheMode = CacheMode.Unconditional,
CacheLength = TimeSpan.FromMinutes(3)
@@ -145,26 +138,36 @@ namespace Emby.Server.Implementations.Updates
}
catch (SerializationException ex)
{
- const string LogTemplate =
- "Failed to deserialize the plugin manifest retrieved from {PluginManifestUrl}. If you " +
- "have specified a custom plugin repository manifest URL with --plugin-manifest-url or " +
- PluginManifestUrlKey + ", please ensure that it is correct.";
- _logger.LogError(ex, LogTemplate, manifestUrl);
+ _logger.LogError(ex, "Failed to deserialize the plugin manifest retrieved from {Manifest}", manifest);
throw;
}
}
}
catch (UriFormatException ex)
{
- const string LogTemplate =
- "The URL configured for the plugin repository manifest URL is not valid: {PluginManifestUrl}. " +
- "Please check the URL configured by --plugin-manifest-url or " + PluginManifestUrlKey;
- _logger.LogError(ex, LogTemplate, manifestUrl);
+ _logger.LogError(ex, "The URL configured for the plugin repository manifest URL is not valid: {Manifest}", manifest);
throw;
}
}
/// <inheritdoc />
+ public async Task<IReadOnlyList<PackageInfo>> GetAvailablePackages(CancellationToken cancellationToken = default)
+ {
+ var result = new List<PackageInfo>();
+ foreach (RepositoryInfo repository in _config.Configuration.PluginRepositories)
+ {
+ if (!repository.Enabled)
+ {
+ continue;
+ }
+
+ result.AddRange(await GetPackages(repository.Url, cancellationToken).ConfigureAwait(true));
+ }
+
+ return result.ToList().AsReadOnly();
+ }
+
+ /// <inheritdoc />
public IEnumerable<PackageInfo> FilterPackages(
IEnumerable<PackageInfo> availablePackages,
string name = null,
diff --git a/Jellyfin.Server/StartupOptions.cs b/Jellyfin.Server/StartupOptions.cs
index cc250b06e..a26114e77 100644
--- a/Jellyfin.Server/StartupOptions.cs
+++ b/Jellyfin.Server/StartupOptions.cs
@@ -80,10 +80,6 @@ namespace Jellyfin.Server
public string? RestartArgs { get; set; }
/// <inheritdoc />
- [Option("plugin-manifest-url", Required = false, HelpText = "A custom URL for the plugin repository JSON manifest")]
- public string? PluginManifestUrl { get; set; }
-
- /// <inheritdoc />
[Option("published-server-url", Required = false, HelpText = "Jellyfin Server URL to publish via auto discover process")]
public Uri? PublishedServerUrl { get; set; }
@@ -95,11 +91,6 @@ namespace Jellyfin.Server
{
var config = new Dictionary<string, string>();
- if (PluginManifestUrl != null)
- {
- config.Add(InstallationManager.PluginManifestUrlKey, PluginManifestUrl);
- }
-
if (NoWebClient)
{
config.Add(ConfigurationExtensions.HostWebClientKey, bool.FalseString);
diff --git a/MediaBrowser.Api/Devices/DeviceService.cs b/MediaBrowser.Api/Devices/DeviceService.cs
index dd3f3e738..18860983e 100644
--- a/MediaBrowser.Api/Devices/DeviceService.cs
+++ b/MediaBrowser.Api/Devices/DeviceService.cs
@@ -92,7 +92,6 @@ namespace MediaBrowser.Api.Devices
var sessions = _authRepo.Get(new AuthenticationInfoQuery
{
DeviceId = request.Id
-
}).Items;
foreach (var session in sessions)
diff --git a/MediaBrowser.Api/PackageService.cs b/MediaBrowser.Api/PackageService.cs
index 444354a99..31ca05759 100644
--- a/MediaBrowser.Api/PackageService.cs
+++ b/MediaBrowser.Api/PackageService.cs
@@ -13,6 +13,18 @@ using Microsoft.Extensions.Logging;
namespace MediaBrowser.Api
{
+ [Route("/Repositories", "GET", Summary = "Gets all package repositories")]
+ [Authenticated]
+ public class GetRepositories : IReturnVoid
+ {
+ }
+
+ [Route("/Repositories", "POST", Summary = "Sets the enabled and existing package repositories")]
+ [Authenticated]
+ public class SetRepositories : List<RepositoryInfo>, IReturnVoid
+ {
+ }
+
/// <summary>
/// Class GetPackage
/// </summary>
@@ -94,6 +106,7 @@ namespace MediaBrowser.Api
public class PackageService : BaseApiService
{
private readonly IInstallationManager _installationManager;
+ private readonly IServerConfigurationManager _serverConfigurationManager;
public PackageService(
ILogger<PackageService> logger,
@@ -103,6 +116,18 @@ namespace MediaBrowser.Api
: base(logger, serverConfigurationManager, httpResultFactory)
{
_installationManager = installationManager;
+ _serverConfigurationManager = serverConfigurationManager;
+ }
+
+ public object Get(GetRepositories request)
+ {
+ var result = _serverConfigurationManager.Configuration.PluginRepositories;
+ return ToOptimizedResult(result);
+ }
+
+ public void Post(SetRepositories request)
+ {
+ _serverConfigurationManager.Configuration.PluginRepositories = request;
}
/// <summary>
diff --git a/MediaBrowser.Common/Updates/IInstallationManager.cs b/MediaBrowser.Common/Updates/IInstallationManager.cs
index 965ffe0ec..a5025aee9 100644
--- a/MediaBrowser.Common/Updates/IInstallationManager.cs
+++ b/MediaBrowser.Common/Updates/IInstallationManager.cs
@@ -41,6 +41,14 @@ namespace MediaBrowser.Common.Updates
IEnumerable<InstallationInfo> CompletedInstallations { get; }
/// <summary>
+ /// Parses a plugin manifest at the supplied URL.
+ /// </summary>
+ /// <param name="manifest">The URL to query.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
+ /// <returns>Task{IReadOnlyList{PackageInfo}}.</returns>
+ Task<IEnumerable<PackageInfo>> GetPackages(string manifest, CancellationToken cancellationToken = default);
+
+ /// <summary>
/// Gets all available packages.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs
index 60b1e6eae..b8ec1c710 100644
--- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs
+++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs
@@ -2,7 +2,9 @@
#pragma warning disable CS1591
using System;
+using System.Collections.Generic;
using MediaBrowser.Model.Dto;
+using MediaBrowser.Model.Updates;
namespace MediaBrowser.Model.Configuration
{
@@ -229,6 +231,8 @@ namespace MediaBrowser.Model.Configuration
public string[] CodecsUsed { get; set; }
+ public List<RepositoryInfo> PluginRepositories { get; set; }
+
public bool IgnoreVirtualInterfaces { get; set; }
public bool EnableExternalContentInSuggestions { get; set; }
@@ -241,11 +245,13 @@ namespace MediaBrowser.Model.Configuration
public bool EnableNewOmdbSupport { get; set; }
public string[] RemoteIPFilter { get; set; }
+
public bool IsRemoteIPFilterBlacklist { get; set; }
public int ImageExtractionTimeoutMs { get; set; }
public PathSubstitution[] PathSubstitutions { get; set; }
+
public bool EnableSimpleArtistDetection { get; set; }
public string[] UninstalledPlugins { get; set; }
@@ -298,6 +304,17 @@ namespace MediaBrowser.Model.Configuration
SortRemoveCharacters = new[] { ",", "&", "-", "{", "}", "'" };
SortRemoveWords = new[] { "the", "a", "an" };
+ PluginRepositories = new List<RepositoryInfo>
+ {
+ new RepositoryInfo
+ {
+ Name = "Jellyfin Stable",
+ Url = "https://repo.jellyfin.org/releases/plugin/manifest-stable.json",
+ Id = Guid.Parse("3721cd80-b10f-4b26-aecd-74c0f0defe97"),
+ Enabled = true
+ }
+ };
+
BaseUrl = string.Empty;
UICulture = "en-US";
@@ -355,6 +372,7 @@ namespace MediaBrowser.Model.Configuration
public class PathSubstitution
{
public string From { get; set; }
+
public string To { get; set; }
}
}
diff --git a/MediaBrowser.Model/Updates/RepositoryInfo.cs b/MediaBrowser.Model/Updates/RepositoryInfo.cs
new file mode 100644
index 000000000..c07abc809
--- /dev/null
+++ b/MediaBrowser.Model/Updates/RepositoryInfo.cs
@@ -0,0 +1,34 @@
+using System;
+
+namespace MediaBrowser.Model.Updates
+{
+ /// <summary>
+ /// Class RepositoryInfo.
+ /// </summary>
+ public class RepositoryInfo
+ {
+ /// <summary>
+ /// Gets or sets the name.
+ /// </summary>
+ /// <value>The name.</value>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets the URL.
+ /// </summary>
+ /// <value>The URL.</value>
+ public string Url { get; set; }
+
+ /// <summary>
+ /// Gets or sets the ID.
+ /// </summary>
+ /// <value>The ID.</value>
+ public Guid Id { get; set; }
+
+ /// <summary>
+ /// Gets or sets the enabled status of the repository.
+ /// </summary>
+ /// <value>The enabled status.</value>
+ public bool Enabled { get; set; }
+ }
+}