PeopleValidationTask.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using MediaBrowser.Common.ScheduledTasks;
  2. using MediaBrowser.Controller.Library;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. namespace MediaBrowser.Server.Implementations.ScheduledTasks
  8. {
  9. /// <summary>
  10. /// Class PeopleValidationTask
  11. /// </summary>
  12. public class PeopleValidationTask : IScheduledTask
  13. {
  14. /// <summary>
  15. /// The _library manager
  16. /// </summary>
  17. private readonly ILibraryManager _libraryManager;
  18. /// <summary>
  19. /// Initializes a new instance of the <see cref="PeopleValidationTask" /> class.
  20. /// </summary>
  21. /// <param name="libraryManager">The library manager.</param>
  22. public PeopleValidationTask(ILibraryManager libraryManager)
  23. {
  24. _libraryManager = libraryManager;
  25. }
  26. /// <summary>
  27. /// Creates the triggers that define when the task will run
  28. /// </summary>
  29. /// <returns>IEnumerable{BaseTaskTrigger}.</returns>
  30. public IEnumerable<ITaskTrigger> GetDefaultTriggers()
  31. {
  32. return new ITaskTrigger[]
  33. {
  34. new DailyTrigger { TimeOfDay = TimeSpan.FromHours(3) },
  35. };
  36. }
  37. /// <summary>
  38. /// Returns the task to be executed
  39. /// </summary>
  40. /// <param name="cancellationToken">The cancellation token.</param>
  41. /// <param name="progress">The progress.</param>
  42. /// <returns>Task.</returns>
  43. public Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
  44. {
  45. return _libraryManager.ValidatePeople(cancellationToken, progress);
  46. }
  47. /// <summary>
  48. /// Gets the name of the task
  49. /// </summary>
  50. /// <value>The name.</value>
  51. public string Name
  52. {
  53. get { return "Refresh people"; }
  54. }
  55. /// <summary>
  56. /// Gets the description.
  57. /// </summary>
  58. /// <value>The description.</value>
  59. public string Description
  60. {
  61. get { return "Updates metadata for actors and directors in your media library."; }
  62. }
  63. /// <summary>
  64. /// Gets the category.
  65. /// </summary>
  66. /// <value>The category.</value>
  67. public string Category
  68. {
  69. get
  70. {
  71. return "Library";
  72. }
  73. }
  74. }
  75. }