2
0

PeopleValidationTask.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. // Every so often
  38. new TaskTriggerInfo
  39. {
  40. Type = TaskTriggerInfo.TriggerInterval,
  41. IntervalTicks = TimeSpan.FromDays(7).Ticks
  42. }
  43. };
  44. }
  45. public string Key => "RefreshPeople";
  46. /// <summary>
  47. /// Returns the task to be executed
  48. /// </summary>
  49. /// <param name="cancellationToken">The cancellation token.</param>
  50. /// <param name="progress">The progress.</param>
  51. /// <returns>Task.</returns>
  52. public Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
  53. {
  54. return _libraryManager.ValidatePeople(cancellationToken, progress);
  55. }
  56. /// <summary>
  57. /// Gets the name of the task
  58. /// </summary>
  59. /// <value>The name.</value>
  60. public string Name => "Refresh people";
  61. /// <summary>
  62. /// Gets the description.
  63. /// </summary>
  64. /// <value>The description.</value>
  65. public string Description => "Updates metadata for actors and directors in your media library.";
  66. /// <summary>
  67. /// Gets the category.
  68. /// </summary>
  69. /// <value>The category.</value>
  70. public string Category => "Library";
  71. }
  72. }