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