FanartBaseProvider.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. using System.Collections.Generic;
  2. using MediaBrowser.Controller.Entities;
  3. using System;
  4. using MediaBrowser.Model.Logging;
  5. namespace MediaBrowser.Controller.Providers
  6. {
  7. /// <summary>
  8. /// Class FanartBaseProvider
  9. /// </summary>
  10. public abstract class FanartBaseProvider : BaseMetadataProvider
  11. {
  12. /// <summary>
  13. /// The LOG o_ FILE
  14. /// </summary>
  15. protected const string LOGO_FILE = "logo.png";
  16. /// <summary>
  17. /// The AR t_ FILE
  18. /// </summary>
  19. protected const string ART_FILE = "clearart.png";
  20. /// <summary>
  21. /// The THUM b_ FILE
  22. /// </summary>
  23. protected const string THUMB_FILE = "thumb.jpg";
  24. /// <summary>
  25. /// The DIS c_ FILE
  26. /// </summary>
  27. protected const string DISC_FILE = "disc.png";
  28. /// <summary>
  29. /// The BANNE r_ FILE
  30. /// </summary>
  31. protected const string BANNER_FILE = "banner.png";
  32. /// <summary>
  33. /// The Backdrop
  34. /// </summary>
  35. protected const string BACKDROP_FILE = "backdrop.jpg";
  36. /// <summary>
  37. /// The Primary image
  38. /// </summary>
  39. protected const string PRIMARY_FILE = "folder.jpg";
  40. /// <summary>
  41. /// The API key
  42. /// </summary>
  43. protected const string APIKey = "5c6b04c68e904cfed1e6cbc9a9e683d4";
  44. protected FanartBaseProvider(ILogManager logManager)
  45. : base(logManager)
  46. {
  47. }
  48. /// <summary>
  49. /// Needses the refresh internal.
  50. /// </summary>
  51. /// <param name="item">The item.</param>
  52. /// <param name="providerInfo">The provider info.</param>
  53. /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
  54. protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
  55. {
  56. if (item.DontFetchMeta) return false;
  57. return DateTime.UtcNow > (providerInfo.LastRefreshed.AddDays(Kernel.Instance.Configuration.MetadataRefreshDays))
  58. && ShouldFetch(item, providerInfo);
  59. }
  60. /// <summary>
  61. /// Gets a value indicating whether [requires internet].
  62. /// </summary>
  63. /// <value><c>true</c> if [requires internet]; otherwise, <c>false</c>.</value>
  64. public override bool RequiresInternet
  65. {
  66. get { return true; }
  67. }
  68. /// <summary>
  69. /// Gets the priority.
  70. /// </summary>
  71. /// <value>The priority.</value>
  72. public override MetadataProviderPriority Priority
  73. {
  74. get { return MetadataProviderPriority.Third; }
  75. }
  76. /// <summary>
  77. /// Shoulds the fetch.
  78. /// </summary>
  79. /// <param name="item">The item.</param>
  80. /// <param name="providerInfo">The provider info.</param>
  81. /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
  82. protected virtual bool ShouldFetch(BaseItem item, BaseProviderInfo providerInfo)
  83. {
  84. return false;
  85. }
  86. #region Result Objects
  87. protected class FanArtImageInfo
  88. {
  89. public string id { get; set; }
  90. public string url { get; set; }
  91. public string likes { get; set; }
  92. }
  93. protected class FanArtMusicInfo
  94. {
  95. public string mbid_id { get; set; }
  96. public List<FanArtImageInfo> musiclogo { get; set; }
  97. public List<FanArtImageInfo> artistbackground { get; set; }
  98. public List<FanArtImageInfo> artistthumb { get; set; }
  99. public List<FanArtImageInfo> hdmusiclogo { get; set; }
  100. public List<FanArtImageInfo> musicbanner { get; set; }
  101. }
  102. protected class FanArtMusicResult
  103. {
  104. public FanArtMusicInfo result { get; set; }
  105. }
  106. #endregion
  107. }
  108. }