From 78f9364b034d73ec80836e2c3a3b62714c8a3bdd Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 2 Nov 2016 16:58:51 -0400 Subject: move classes to portable server project --- .../ScheduledTasks/PeopleValidationTask.cs | 94 ++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 Emby.Server.Implementations/ScheduledTasks/PeopleValidationTask.cs (limited to 'Emby.Server.Implementations/ScheduledTasks/PeopleValidationTask.cs') diff --git a/Emby.Server.Implementations/ScheduledTasks/PeopleValidationTask.cs b/Emby.Server.Implementations/ScheduledTasks/PeopleValidationTask.cs new file mode 100644 index 0000000000..51122226bd --- /dev/null +++ b/Emby.Server.Implementations/ScheduledTasks/PeopleValidationTask.cs @@ -0,0 +1,94 @@ +using MediaBrowser.Controller.Library; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using MediaBrowser.Controller; +using MediaBrowser.Model.Tasks; + +namespace Emby.Server.Implementations.ScheduledTasks +{ + /// + /// Class PeopleValidationTask + /// + public class PeopleValidationTask : IScheduledTask + { + /// + /// The _library manager + /// + private readonly ILibraryManager _libraryManager; + + private readonly IServerApplicationHost _appHost; + + /// + /// Initializes a new instance of the class. + /// + /// The library manager. + public PeopleValidationTask(ILibraryManager libraryManager, IServerApplicationHost appHost) + { + _libraryManager = libraryManager; + _appHost = appHost; + } + + /// + /// Creates the triggers that define when the task will run + /// + public IEnumerable GetDefaultTriggers() + { + // Randomize the default start hour because this operation can really hammer internet metadata providers + var startHour = new Random(_appHost.SystemId.GetHashCode()).Next(0, 8); + + return new[] { + + // Every so often + new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerDaily, TimeOfDayTicks = TimeSpan.FromHours(startHour).Ticks} + }; + } + + public string Key + { + get { return "RefreshPeople"; } + } + + /// + /// Returns the task to be executed + /// + /// The cancellation token. + /// The progress. + /// Task. + public Task Execute(CancellationToken cancellationToken, IProgress progress) + { + return _libraryManager.ValidatePeople(cancellationToken, progress); + } + + /// + /// Gets the name of the task + /// + /// The name. + public string Name + { + get { return "Refresh people"; } + } + + /// + /// Gets the description. + /// + /// The description. + public string Description + { + get { return "Updates metadata for actors and directors in your media library."; } + } + + /// + /// Gets the category. + /// + /// The category. + public string Category + { + get + { + return "Library"; + } + } + } +} -- cgit v1.2.3