FanartBaseProvider.cs 4.0 KB

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