using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Model.Tasks;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Controller.ScheduledTasks
{
///
/// Class RefreshMediaLibraryTask
///
[Export(typeof(IScheduledTask))]
public class RefreshMediaLibraryTask : BaseScheduledTask
{
///
/// Gets the default triggers.
///
/// IEnumerable{BaseTaskTrigger}.
protected override IEnumerable GetDefaultTriggers()
{
return new BaseTaskTrigger[] {
new StartupTrigger(Kernel),
new SystemEventTrigger{ SystemEvent = SystemEvent.WakeFromSleep},
new IntervalTrigger{ Interval = TimeSpan.FromHours(2)}
};
}
///
/// Executes the internal.
///
/// The cancellation token.
/// The progress.
/// Task.
protected override Task ExecuteInternal(CancellationToken cancellationToken, IProgress progress)
{
cancellationToken.ThrowIfCancellationRequested();
progress.Report(0);
return Kernel.LibraryManager.ValidateMediaLibrary(progress, cancellationToken);
}
///
/// Gets the name.
///
/// The name.
public override string Name
{
get { return "Scan media library"; }
}
///
/// Gets the description.
///
/// The description.
public override string Description
{
get { return "Scans your media library and refreshes metatata based on configuration."; }
}
///
/// Gets the category.
///
/// The category.
public override string Category
{
get
{
return "Library";
}
}
}
}