PeopleValidationTask.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using MediaBrowser.Controller.Library;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Threading;
  5. using System.Threading.Tasks;
  6. using MediaBrowser.Controller;
  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. public PeopleValidationTask(ILibraryManager libraryManager, IServerApplicationHost appHost)
  25. {
  26. _libraryManager = libraryManager;
  27. _appHost = appHost;
  28. }
  29. /// <summary>
  30. /// Creates the triggers that define when the task will run
  31. /// </summary>
  32. public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
  33. {
  34. return new[]
  35. {
  36. // Every so often
  37. new TaskTriggerInfo
  38. {
  39. Type = TaskTriggerInfo.TriggerInterval,
  40. IntervalTicks = TimeSpan.FromDays(7).Ticks
  41. }
  42. };
  43. }
  44. public string Key
  45. {
  46. get { return "RefreshPeople"; }
  47. }
  48. /// <summary>
  49. /// Returns the task to be executed
  50. /// </summary>
  51. /// <param name="cancellationToken">The cancellation token.</param>
  52. /// <param name="progress">The progress.</param>
  53. /// <returns>Task.</returns>
  54. public Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
  55. {
  56. return _libraryManager.ValidatePeople(cancellationToken, progress);
  57. }
  58. /// <summary>
  59. /// Gets the name of the task
  60. /// </summary>
  61. /// <value>The name.</value>
  62. public string Name
  63. {
  64. get { return "Refresh people"; }
  65. }
  66. /// <summary>
  67. /// Gets the description.
  68. /// </summary>
  69. /// <value>The description.</value>
  70. public string Description
  71. {
  72. get { return "Updates metadata for actors and directors in your media library."; }
  73. }
  74. /// <summary>
  75. /// Gets the category.
  76. /// </summary>
  77. /// <value>The category.</value>
  78. public string Category
  79. {
  80. get
  81. {
  82. return "Library";
  83. }
  84. }
  85. }
  86. }