2
0

PeopleValidationTask.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading;
  4. using System.Threading.Tasks;
  5. using MediaBrowser.Controller;
  6. using MediaBrowser.Controller.Library;
  7. using MediaBrowser.Model.Tasks;
  8. namespace Emby.Server.Implementations.ScheduledTasks
  9. {
  10. /// <summary>
  11. /// Class PeopleValidationTask.
  12. /// </summary>
  13. public class PeopleValidationTask : IScheduledTask
  14. {
  15. /// <summary>
  16. /// The library manager.
  17. /// </summary>
  18. private readonly ILibraryManager _libraryManager;
  19. private readonly IServerApplicationHost _appHost;
  20. /// <summary>
  21. /// Initializes a new instance of the <see cref="PeopleValidationTask" /> class.
  22. /// </summary>
  23. /// <param name="libraryManager">The library manager.</param>
  24. /// <param name="appHost">The server application host</param>
  25. public PeopleValidationTask(ILibraryManager libraryManager, IServerApplicationHost appHost)
  26. {
  27. _libraryManager = libraryManager;
  28. _appHost = appHost;
  29. }
  30. /// <summary>
  31. /// Creates the triggers that define when the task will run.
  32. /// </summary>
  33. public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
  34. {
  35. return new[]
  36. {
  37. new TaskTriggerInfo
  38. {
  39. Type = TaskTriggerInfo.TriggerInterval,
  40. IntervalTicks = TimeSpan.FromDays(7).Ticks
  41. }
  42. };
  43. }
  44. /// <summary>
  45. /// Returns the task to be executed.
  46. /// </summary>
  47. /// <param name="cancellationToken">The cancellation token.</param>
  48. /// <param name="progress">The progress.</param>
  49. /// <returns>Task.</returns>
  50. public Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
  51. {
  52. return _libraryManager.ValidatePeople(cancellationToken, progress);
  53. }
  54. public string Name => "Refresh People";
  55. public string Description => "Updates metadata for actors and directors in your media library.";
  56. public string Category => "Library";
  57. public string Key => "RefreshPeople";
  58. public bool IsHidden => false;
  59. public bool IsEnabled => true;
  60. public bool IsLogged => true;
  61. }
  62. }