PeopleValidationTask.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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(2) },
  35. new IntervalTrigger{ Interval = TimeSpan.FromHours(12)}
  36. };
  37. }
  38. /// <summary>
  39. /// Returns the task to be executed
  40. /// </summary>
  41. /// <param name="cancellationToken">The cancellation token.</param>
  42. /// <param name="progress">The progress.</param>
  43. /// <returns>Task.</returns>
  44. public Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
  45. {
  46. return _libraryManager.ValidatePeople(cancellationToken, progress);
  47. }
  48. /// <summary>
  49. /// Gets the name of the task
  50. /// </summary>
  51. /// <value>The name.</value>
  52. public string Name
  53. {
  54. get { return "Refresh people"; }
  55. }
  56. /// <summary>
  57. /// Gets the description.
  58. /// </summary>
  59. /// <value>The description.</value>
  60. public string Description
  61. {
  62. get { return "Updates metadata for actors and directors in your media library."; }
  63. }
  64. /// <summary>
  65. /// Gets the category.
  66. /// </summary>
  67. /// <value>The category.</value>
  68. public string Category
  69. {
  70. get
  71. {
  72. return "Library";
  73. }
  74. }
  75. }
  76. }