jellyfin/MediaBrowser.Server.Implementations/ScheduledTasks/RefreshMediaLibraryTask.cs

95 lines
2.7 KiB
C#
Raw Normal View History

2013-02-21 01:33:05 +00:00
using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Controller.Library;
2013-05-18 21:47:50 +00:00
using MediaBrowser.Server.Implementations.Library;
2013-02-21 01:33:05 +00:00
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Server.Implementations.ScheduledTasks
2013-02-21 01:33:05 +00:00
{
/// <summary>
/// Class RefreshMediaLibraryTask
/// </summary>
2014-12-13 21:26:04 +00:00
public class RefreshMediaLibraryTask : IScheduledTask, IHasKey
2013-02-21 01:33:05 +00:00
{
/// <summary>
/// The _library manager
/// </summary>
private readonly ILibraryManager _libraryManager;
2013-02-23 07:57:11 +00:00
/// <summary>
/// Initializes a new instance of the <see cref="RefreshMediaLibraryTask" /> class.
/// </summary>
/// <param name="libraryManager">The library manager.</param>
public RefreshMediaLibraryTask(ILibraryManager libraryManager)
2013-02-23 07:57:11 +00:00
{
_libraryManager = libraryManager;
2013-02-23 07:57:11 +00:00
}
2013-02-21 01:33:05 +00:00
/// <summary>
/// Gets the default triggers.
/// </summary>
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
public IEnumerable<ITaskTrigger> GetDefaultTriggers()
2013-02-21 01:33:05 +00:00
{
2013-02-24 21:53:54 +00:00
return new ITaskTrigger[] {
2013-02-21 01:33:05 +00:00
2013-02-23 07:57:11 +00:00
new StartupTrigger(),
2013-02-21 01:33:05 +00:00
2015-07-29 03:42:03 +00:00
new IntervalTrigger{ Interval = TimeSpan.FromHours(8)}
2013-02-21 01:33:05 +00:00
};
}
/// <summary>
/// Executes the internal.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="progress">The progress.</param>
/// <returns>Task.</returns>
public Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
2013-02-21 01:33:05 +00:00
{
cancellationToken.ThrowIfCancellationRequested();
2013-02-22 04:23:06 +00:00
progress.Report(0);
2013-02-21 01:33:05 +00:00
return ((LibraryManager)_libraryManager).ValidateMediaLibraryInternal(progress, cancellationToken);
2013-02-21 01:33:05 +00:00
}
/// <summary>
/// Gets the name.
/// </summary>
/// <value>The name.</value>
public string Name
2013-02-21 01:33:05 +00:00
{
get { return "Scan media library"; }
}
/// <summary>
/// Gets the description.
/// </summary>
/// <value>The description.</value>
public string Description
2013-02-21 01:33:05 +00:00
{
get { return "Scans your media library and refreshes metatata based on configuration."; }
}
/// <summary>
/// Gets the category.
/// </summary>
/// <value>The category.</value>
public string Category
2013-02-21 01:33:05 +00:00
{
get
{
return "Library";
}
}
2014-12-13 21:26:04 +00:00
public string Key
{
get { return "RefreshLibrary"; }
}
2013-02-21 01:33:05 +00:00
}
}