Merge pull request #774 from dkanada/plugin

reimplement support for plugin repository
This commit is contained in:
Vasily 2019-02-03 16:42:29 +03:00 committed by GitHub
commit a50fb922c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 166 additions and 94 deletions

View File

@ -15,6 +15,7 @@
- [cvium](https://github.com/cvium)
- [wtayl0r](https://github.com/wtayl0r)
- [TtheCreator](https://github.com/Tthecreator)
- [dkanada](https://github.com/dkanada)
- [LogicalPhallacy](https://github.com/LogicalPhallacy/)
- [RazeLighter777](https://github.com/RazeLighter777)

View File

@ -68,8 +68,6 @@ namespace Emby.Server.Implementations.ScheduledTasks
};
}
public string Key => "RefreshChapterImages";
/// <summary>
/// Returns the task to be executed
/// </summary>
@ -161,22 +159,18 @@ namespace Emby.Server.Implementations.ScheduledTasks
}
}
/// <summary>
/// Gets the name of the task
/// </summary>
/// <value>The name.</value>
public string Name => "Chapter image extraction";
/// <summary>
/// Gets the description.
/// </summary>
/// <value>The description.</value>
public string Description => "Creates thumbnails for videos that have chapters.";
/// <summary>
/// Gets the category.
/// </summary>
/// <value>The category.</value>
public string Category => "Library";
public string Key => "RefreshChapterImages";
public bool IsHidden => false;
public bool IsEnabled => true;
public bool IsLogged => true;
}
}

View File

@ -158,31 +158,15 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
}
}
/// <summary>
/// Gets the name of the task
/// </summary>
/// <value>The name.</value>
public string Name => "Cache file cleanup";
public string Description => "Deletes cache files no longer needed by the system";
public string Category => "Maintenance";
public string Key => "DeleteCacheFiles";
/// <summary>
/// Gets the description.
/// </summary>
/// <value>The description.</value>
public string Description => "Deletes cache files no longer needed by the system";
/// <summary>
/// Gets the category.
/// </summary>
/// <value>The category.</value>
public string Category => "Maintenance";
/// <summary>
/// Gets a value indicating whether this instance is hidden.
/// </summary>
/// <value><c>true</c> if this instance is hidden; otherwise, <c>false</c>.</value>
public bool IsHidden => true;
public bool IsHidden => false;
public bool IsEnabled => true;

View File

@ -81,31 +81,15 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
return Task.CompletedTask;
}
public string Key => "CleanLogFiles";
/// <summary>
/// Gets the name of the task
/// </summary>
/// <value>The name.</value>
public string Name => "Log file cleanup";
/// <summary>
/// Gets the description.
/// </summary>
/// <value>The description.</value>
public string Description => string.Format("Deletes log files that are more than {0} days old.", ConfigurationManager.CommonConfiguration.LogFileRetentionDays);
/// <summary>
/// Gets the category.
/// </summary>
/// <value>The category.</value>
public string Category => "Maintenance";
/// <summary>
/// Gets a value indicating whether this instance is hidden.
/// </summary>
/// <value><c>true</c> if this instance is hidden; otherwise, <c>false</c>.</value>
public bool IsHidden => true;
public string Key => "CleanLogFiles";
public bool IsHidden => false;
public bool IsEnabled => true;

View File

@ -47,8 +47,6 @@ namespace Emby.Server.Implementations.ScheduledTasks
};
}
public string Key => "RefreshPeople";
/// <summary>
/// Returns the task to be executed
/// </summary>
@ -60,22 +58,18 @@ namespace Emby.Server.Implementations.ScheduledTasks
return _libraryManager.ValidatePeople(cancellationToken, progress);
}
/// <summary>
/// Gets the name of the task
/// </summary>
/// <value>The name.</value>
public string Name => "Refresh people";
/// <summary>
/// Gets the description.
/// </summary>
/// <value>The description.</value>
public string Description => "Updates metadata for actors and directors in your media library.";
/// <summary>
/// Gets the category.
/// </summary>
/// <value>The category.</value>
public string Category => "Library";
public string Key => "RefreshPeople";
public bool IsHidden => false;
public bool IsEnabled => true;
public bool IsLogged => true;
}
}

View File

@ -0,0 +1,119 @@
using MediaBrowser.Common;
using MediaBrowser.Common.Updates;
using MediaBrowser.Model.Net;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.Progress;
using MediaBrowser.Model.Tasks;
using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.ScheduledTasks
{
/// <summary>
/// Plugin Update Task
/// </summary>
public class PluginUpdateTask : IScheduledTask, IConfigurableScheduledTask
{
/// <summary>
/// The _logger
/// </summary>
private readonly ILogger _logger;
private readonly IInstallationManager _installationManager;
private readonly IApplicationHost _appHost;
public PluginUpdateTask(ILogger logger, IInstallationManager installationManager, IApplicationHost appHost)
{
_logger = logger;
_installationManager = installationManager;
_appHost = appHost;
}
/// <summary>
/// Creates the triggers that define when the task will run
/// </summary>
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{
return new[] {
// At startup
new TaskTriggerInfo {Type = TaskTriggerInfo.TriggerStartup},
// Every so often
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks}
};
}
/// <summary>
/// Update installed plugins
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="progress">The progress.</param>
/// <returns>Task.</returns>
public async Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
{
progress.Report(0);
var packagesToInstall = (await _installationManager.GetAvailablePluginUpdates(typeof(PluginUpdateTask).Assembly.GetName().Version, true, cancellationToken).ConfigureAwait(false)).ToList();
progress.Report(10);
var numComplete = 0;
foreach (var package in packagesToInstall)
{
cancellationToken.ThrowIfCancellationRequested();
try
{
await _installationManager.InstallPackage(package, true, new SimpleProgress<double>(), cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
// InstallPackage has it's own inner cancellation token, so only throw this if it's ours
if (cancellationToken.IsCancellationRequested)
{
throw;
}
}
catch (HttpException ex)
{
_logger.LogError(ex, "Error downloading {0}", package.name);
}
catch (IOException ex)
{
_logger.LogError(ex, "Error updating {0}", package.name);
}
// Update progress
lock (progress)
{
numComplete++;
progress.Report(90.0 * numComplete / packagesToInstall.Count + 10);
}
}
progress.Report(100);
}
public string Name => "Check for plugin updates";
public string Description => "Downloads and installs updates for plugins that are configured to update automatically.";
public string Category => "Application";
public string Key => "PluginUpdates";
public bool IsHidden => false;
public bool IsEnabled => true;
public bool IsLogged => true;
}
}

View File

@ -58,24 +58,18 @@ namespace Emby.Server.Implementations.ScheduledTasks
return ((LibraryManager)_libraryManager).ValidateMediaLibraryInternal(progress, cancellationToken);
}
/// <summary>
/// Gets the name.
/// </summary>
/// <value>The name.</value>
public string Name => "Scan media library";
/// <summary>
/// Gets the description.
/// </summary>
/// <value>The description.</value>
public string Description => "Scans your media library and refreshes metatata based on configuration.";
/// <summary>
/// Gets the category.
/// </summary>
/// <value>The category.</value>
public string Category => "Library";
public string Key => "RefreshLibrary";
public bool IsHidden => false;
public bool IsEnabled => true;
public bool IsLogged => true;
}
}

View File

@ -169,10 +169,8 @@ namespace Emby.Server.Implementations.Updates
string packageType = null,
Version applicationVersion = null)
{
// TODO cvium: when plugins get back this would need to be fixed
// var packages = await GetAvailablePackagesWithoutRegistrationInfo(cancellationToken).ConfigureAwait(false);
return Task.FromResult(new List<PackageInfo>()); //FilterPackages(packages, packageType, applicationVersion);
var packages = await GetAvailablePackagesWithoutRegistrationInfo(cancellationToken).ConfigureAwait(false);
return FilterPackages(packages, packageType, applicationVersion);
}
/// <summary>
@ -184,12 +182,10 @@ namespace Emby.Server.Implementations.Updates
{
using (var response = await _httpClient.SendAsync(new HttpRequestOptions
{
Url = "https://www.mb3admin.local/admin/service/EmbyPackages.json",
Url = "https://repo.jellyfin.org/releases/plugin/manifest.json",
CancellationToken = cancellationToken,
Progress = new SimpleProgress<double>(),
CacheLength = GetCacheLength(),
CacheMode = CacheMode.Unconditional
CacheLength = GetCacheLength()
}, "GET").ConfigureAwait(false))
{
using (var stream = response.Content)

View File

@ -36,12 +36,6 @@ namespace MediaBrowser.Providers.MediaInfo
_json = json;
}
public string Name => "Download missing subtitles";
public string Description => "Searches the internet for missing subtitles based on metadata configuration.";
public string Category => "Library";
private SubtitleOptions GetOptions()
{
return _config.GetConfiguration<SubtitleOptions>("subtitles");
@ -204,6 +198,18 @@ namespace MediaBrowser.Providers.MediaInfo
};
}
public string Name => "Download missing subtitles";
public string Description => "Searches the internet for missing subtitles based on metadata configuration.";
public string Category => "Library";
public string Key => "DownloadSubtitles";
public bool IsHidden => false;
public bool IsEnabled => true;
public bool IsLogged => true;
}
}