IMetadataProvider.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using MediaBrowser.Model.Entities;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Threading;
  5. using System.Threading.Tasks;
  6. namespace MediaBrowser.Controller.Providers
  7. {
  8. /// <summary>
  9. /// Marker interface
  10. /// </summary>
  11. public interface IMetadataProvider
  12. {
  13. /// <summary>
  14. /// Gets the name.
  15. /// </summary>
  16. /// <value>The name.</value>
  17. string Name { get; }
  18. }
  19. public interface IMetadataProvider<TItemType> : IMetadataProvider
  20. where TItemType : IHasMetadata
  21. {
  22. }
  23. public interface ILocalMetadataProvider : IMetadataProvider
  24. {
  25. /// <summary>
  26. /// Determines whether [has local metadata] [the specified item].
  27. /// </summary>
  28. /// <param name="item">The item.</param>
  29. /// <returns><c>true</c> if [has local metadata] [the specified item]; otherwise, <c>false</c>.</returns>
  30. bool HasLocalMetadata(IHasMetadata item);
  31. }
  32. public interface IRemoteMetadataProvider : IMetadataProvider
  33. {
  34. }
  35. public interface IRemoteMetadataProvider<TItemType> : IMetadataProvider<TItemType>, IRemoteMetadataProvider
  36. where TItemType : IHasMetadata
  37. {
  38. Task<MetadataResult<TItemType>> GetMetadata(ItemId id, CancellationToken cancellationToken);
  39. }
  40. public interface ILocalMetadataProvider<TItemType> : IMetadataProvider<TItemType>, ILocalMetadataProvider
  41. where TItemType : IHasMetadata
  42. {
  43. Task<MetadataResult<TItemType>> GetMetadata(string path, CancellationToken cancellationToken);
  44. }
  45. public interface IHasChangeMonitor
  46. {
  47. /// <summary>
  48. /// Determines whether the specified date has changed.
  49. /// </summary>
  50. /// <param name="item">The item.</param>
  51. /// <param name="date">The date.</param>
  52. /// <returns><c>true</c> if the specified date has changed; otherwise, <c>false</c>.</returns>
  53. bool HasChanged(IHasMetadata item, DateTime date);
  54. }
  55. public enum MetadataProviderType
  56. {
  57. Embedded = 0,
  58. Local = 1,
  59. Remote = 2
  60. }
  61. public class MetadataResult<T>
  62. where T : IHasMetadata
  63. {
  64. public bool HasMetadata { get; set; }
  65. public T Item { get; set; }
  66. }
  67. public class ItemId : IHasProviderIds
  68. {
  69. public string Name { get; set; }
  70. public string MetadataLanguage { get; set; }
  71. public string MetadataCountryCode { get; set; }
  72. public Dictionary<string, string> ProviderIds { get; set; }
  73. public ItemId()
  74. {
  75. ProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
  76. }
  77. }
  78. }