mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-04-24 14:08:44 -04:00
Merge pull request #3244 from jellyfin/custom-repos
Initial implementation for custom plugin repositories
This commit is contained in:
commit
552a358c9c
10 changed files with 128 additions and 35 deletions
|
@ -17,7 +17,6 @@ namespace Emby.Server.Implementations
|
||||||
{
|
{
|
||||||
{ HostWebClientKey, bool.TrueString },
|
{ HostWebClientKey, bool.TrueString },
|
||||||
{ HttpListenerHost.DefaultRedirectKey, "web/index.html" },
|
{ HttpListenerHost.DefaultRedirectKey, "web/index.html" },
|
||||||
{ InstallationManager.PluginManifestUrlKey, "https://repo.jellyfin.org/releases/plugin/manifest-stable.json" },
|
|
||||||
{ FfmpegProbeSizeKey, "1G" },
|
{ FfmpegProbeSizeKey, "1G" },
|
||||||
{ FfmpegAnalyzeDurationKey, "200M" },
|
{ FfmpegAnalyzeDurationKey, "200M" },
|
||||||
{ PlaylistsAllowDuplicatesKey, bool.TrueString }
|
{ PlaylistsAllowDuplicatesKey, bool.TrueString }
|
||||||
|
|
|
@ -36,11 +36,6 @@ namespace Emby.Server.Implementations
|
||||||
/// </summary>
|
/// </summary>
|
||||||
string RestartArgs { get; }
|
string RestartArgs { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the value of the --plugin-manifest-url command line option.
|
|
||||||
/// </summary>
|
|
||||||
string PluginManifestUrl { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the value of the --published-server-url command line option.
|
/// Gets the value of the --published-server-url command line option.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -19,6 +19,7 @@ using MediaBrowser.Common.Updates;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Model.Events;
|
using MediaBrowser.Model.Events;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
|
using MediaBrowser.Model.Net;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
using MediaBrowser.Model.Updates;
|
using MediaBrowser.Model.Updates;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
@ -31,11 +32,6 @@ namespace Emby.Server.Implementations.Updates
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class InstallationManager : IInstallationManager
|
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>
|
/// <summary>
|
||||||
/// The logger.
|
/// The logger.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -122,16 +118,14 @@ namespace Emby.Server.Implementations.Updates
|
||||||
public IEnumerable<InstallationInfo> CompletedInstallations => _completedInstallationsInternal;
|
public IEnumerable<InstallationInfo> CompletedInstallations => _completedInstallationsInternal;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <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
|
try
|
||||||
{
|
{
|
||||||
using (var response = await _httpClient.SendAsync(
|
using (var response = await _httpClient.SendAsync(
|
||||||
new HttpRequestOptions
|
new HttpRequestOptions
|
||||||
{
|
{
|
||||||
Url = manifestUrl,
|
Url = manifest,
|
||||||
CancellationToken = cancellationToken,
|
CancellationToken = cancellationToken,
|
||||||
CacheMode = CacheMode.Unconditional,
|
CacheMode = CacheMode.Unconditional,
|
||||||
CacheLength = TimeSpan.FromMinutes(3)
|
CacheLength = TimeSpan.FromMinutes(3)
|
||||||
|
@ -145,23 +139,33 @@ namespace Emby.Server.Implementations.Updates
|
||||||
}
|
}
|
||||||
catch (SerializationException ex)
|
catch (SerializationException ex)
|
||||||
{
|
{
|
||||||
const string LogTemplate =
|
_logger.LogError(ex, "Failed to deserialize the plugin manifest retrieved from {Manifest}", manifest);
|
||||||
"Failed to deserialize the plugin manifest retrieved from {PluginManifestUrl}. If you " +
|
return Enumerable.Empty<PackageInfo>();
|
||||||
"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);
|
|
||||||
throw;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (UriFormatException ex)
|
catch (UriFormatException ex)
|
||||||
{
|
{
|
||||||
const string LogTemplate =
|
_logger.LogError(ex, "The URL configured for the plugin repository manifest URL is not valid: {Manifest}", manifest);
|
||||||
"The URL configured for the plugin repository manifest URL is not valid: {PluginManifestUrl}. " +
|
return Enumerable.Empty<PackageInfo>();
|
||||||
"Please check the URL configured by --plugin-manifest-url or " + PluginManifestUrlKey;
|
|
||||||
_logger.LogError(ex, LogTemplate, manifestUrl);
|
|
||||||
throw;
|
|
||||||
}
|
}
|
||||||
|
catch (HttpException ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "An error occurred while accessing the plugin manifest: {Manifest}", manifest);
|
||||||
|
return Enumerable.Empty<PackageInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<IReadOnlyList<PackageInfo>> GetAvailablePackages(CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
var result = new List<PackageInfo>();
|
||||||
|
foreach (RepositoryInfo repository in _config.Configuration.PluginRepositories)
|
||||||
|
{
|
||||||
|
result.AddRange(await GetPackages(repository.Url, cancellationToken).ConfigureAwait(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.AsReadOnly();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|
|
@ -20,6 +20,7 @@ namespace Jellyfin.Server.Migrations
|
||||||
typeof(Routines.CreateUserLoggingConfigFile),
|
typeof(Routines.CreateUserLoggingConfigFile),
|
||||||
typeof(Routines.MigrateActivityLogDb),
|
typeof(Routines.MigrateActivityLogDb),
|
||||||
typeof(Routines.RemoveDuplicateExtras),
|
typeof(Routines.RemoveDuplicateExtras),
|
||||||
|
typeof(Routines.AddDefaultPluginRepository),
|
||||||
typeof(Routines.MigrateUserDb)
|
typeof(Routines.MigrateUserDb)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
using System;
|
||||||
|
using MediaBrowser.Controller.Configuration;
|
||||||
|
using MediaBrowser.Model.Updates;
|
||||||
|
|
||||||
|
namespace Jellyfin.Server.Migrations.Routines
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Migration to initialize system configuration with the default plugin repository.
|
||||||
|
/// </summary>
|
||||||
|
public class AddDefaultPluginRepository : IMigrationRoutine
|
||||||
|
{
|
||||||
|
private readonly IServerConfigurationManager _serverConfigurationManager;
|
||||||
|
|
||||||
|
private readonly RepositoryInfo _defaultRepositoryInfo = new RepositoryInfo
|
||||||
|
{
|
||||||
|
Name = "Jellyfin Stable",
|
||||||
|
Url = "https://repo.jellyfin.org/releases/plugin/manifest-stable.json"
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="AddDefaultPluginRepository"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serverConfigurationManager">Instance of the <see cref="IServerConfigurationManager"/> interface.</param>
|
||||||
|
public AddDefaultPluginRepository(IServerConfigurationManager serverConfigurationManager)
|
||||||
|
{
|
||||||
|
_serverConfigurationManager = serverConfigurationManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public Guid Id => Guid.Parse("EB58EBEE-9514-4B9B-8225-12E1A40020DF");
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public string Name => "AddDefaultPluginRepository";
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void Perform()
|
||||||
|
{
|
||||||
|
_serverConfigurationManager.Configuration.PluginRepositories.Add(_defaultRepositoryInfo);
|
||||||
|
_serverConfigurationManager.SaveConfiguration();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -79,10 +79,6 @@ namespace Jellyfin.Server
|
||||||
[Option("restartargs", Required = false, HelpText = "Arguments for restart script.")]
|
[Option("restartargs", Required = false, HelpText = "Arguments for restart script.")]
|
||||||
public string? RestartArgs { get; set; }
|
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 />
|
/// <inheritdoc />
|
||||||
[Option("published-server-url", Required = false, HelpText = "Jellyfin Server URL to publish via auto discover process")]
|
[Option("published-server-url", Required = false, HelpText = "Jellyfin Server URL to publish via auto discover process")]
|
||||||
public Uri? PublishedServerUrl { get; set; }
|
public Uri? PublishedServerUrl { get; set; }
|
||||||
|
@ -95,11 +91,6 @@ namespace Jellyfin.Server
|
||||||
{
|
{
|
||||||
var config = new Dictionary<string, string>();
|
var config = new Dictionary<string, string>();
|
||||||
|
|
||||||
if (PluginManifestUrl != null)
|
|
||||||
{
|
|
||||||
config.Add(InstallationManager.PluginManifestUrlKey, PluginManifestUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NoWebClient)
|
if (NoWebClient)
|
||||||
{
|
{
|
||||||
config.Add(ConfigurationExtensions.HostWebClientKey, bool.FalseString);
|
config.Add(ConfigurationExtensions.HostWebClientKey, bool.FalseString);
|
||||||
|
|
|
@ -13,6 +13,18 @@ using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace MediaBrowser.Api
|
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>
|
/// <summary>
|
||||||
/// Class GetPackage.
|
/// Class GetPackage.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -94,6 +106,7 @@ namespace MediaBrowser.Api
|
||||||
public class PackageService : BaseApiService
|
public class PackageService : BaseApiService
|
||||||
{
|
{
|
||||||
private readonly IInstallationManager _installationManager;
|
private readonly IInstallationManager _installationManager;
|
||||||
|
private readonly IServerConfigurationManager _serverConfigurationManager;
|
||||||
|
|
||||||
public PackageService(
|
public PackageService(
|
||||||
ILogger<PackageService> logger,
|
ILogger<PackageService> logger,
|
||||||
|
@ -103,6 +116,19 @@ namespace MediaBrowser.Api
|
||||||
: base(logger, serverConfigurationManager, httpResultFactory)
|
: base(logger, serverConfigurationManager, httpResultFactory)
|
||||||
{
|
{
|
||||||
_installationManager = installationManager;
|
_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;
|
||||||
|
_serverConfigurationManager.SaveConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -40,6 +40,14 @@ namespace MediaBrowser.Common.Updates
|
||||||
/// </summary>
|
/// </summary>
|
||||||
IEnumerable<InstallationInfo> CompletedInstallations { get; }
|
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>
|
/// <summary>
|
||||||
/// Gets all available packages.
|
/// Gets all available packages.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
#pragma warning disable CS1591
|
#pragma warning disable CS1591
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
|
using MediaBrowser.Model.Updates;
|
||||||
|
|
||||||
namespace MediaBrowser.Model.Configuration
|
namespace MediaBrowser.Model.Configuration
|
||||||
{
|
{
|
||||||
|
@ -229,6 +231,8 @@ namespace MediaBrowser.Model.Configuration
|
||||||
|
|
||||||
public string[] CodecsUsed { get; set; }
|
public string[] CodecsUsed { get; set; }
|
||||||
|
|
||||||
|
public List<RepositoryInfo> PluginRepositories { get; set; }
|
||||||
|
|
||||||
public bool IgnoreVirtualInterfaces { get; set; }
|
public bool IgnoreVirtualInterfaces { get; set; }
|
||||||
|
|
||||||
public bool EnableExternalContentInSuggestions { get; set; }
|
public bool EnableExternalContentInSuggestions { get; set; }
|
||||||
|
|
23
MediaBrowser.Model/Updates/RepositoryInfo.cs
Normal file
23
MediaBrowser.Model/Updates/RepositoryInfo.cs
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#nullable disable
|
||||||
|
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; }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue