jellyfin-server/MediaBrowser.Controller/Providers/FanartBaseProvider.cs

141 lines
4.2 KiB
C#
Raw Normal View History

2013-03-04 15:13:03 +00:00
using System.Threading;
using MediaBrowser.Controller.Configuration;
using System.Collections.Generic;
2013-03-04 14:34:00 +00:00
using MediaBrowser.Controller.Entities;
2013-02-21 01:33:05 +00:00
using System;
2013-03-02 17:59:15 +00:00
using MediaBrowser.Model.Logging;
2013-02-21 01:33:05 +00:00
namespace MediaBrowser.Controller.Providers
{
2013-03-05 15:45:59 +00:00
class FanArtProviderException : ApplicationException
{
public FanArtProviderException(string msg)
: base(msg)
{
}
}
2013-02-21 01:33:05 +00:00
/// <summary>
/// Class FanartBaseProvider
/// </summary>
public abstract class FanartBaseProvider : BaseMetadataProvider
{
2013-03-04 15:13:03 +00:00
protected static readonly SemaphoreSlim FanArtResourcePool = new SemaphoreSlim(5,5);
2013-02-21 01:33:05 +00:00
/// <summary>
/// The LOG o_ FILE
/// </summary>
protected const string LOGO_FILE = "logo.png";
2013-03-04 14:34:00 +00:00
2013-02-21 01:33:05 +00:00
/// <summary>
/// The AR t_ FILE
/// </summary>
protected const string ART_FILE = "clearart.png";
2013-03-04 14:34:00 +00:00
2013-02-21 01:33:05 +00:00
/// <summary>
/// The THUM b_ FILE
/// </summary>
protected const string THUMB_FILE = "thumb.jpg";
2013-03-04 14:34:00 +00:00
2013-02-21 01:33:05 +00:00
/// <summary>
/// The DIS c_ FILE
/// </summary>
protected const string DISC_FILE = "disc.png";
2013-03-04 14:34:00 +00:00
2013-02-21 01:33:05 +00:00
/// <summary>
/// The BANNE r_ FILE
/// </summary>
protected const string BANNER_FILE = "banner.png";
2013-03-04 14:34:00 +00:00
/// <summary>
/// The Backdrop
/// </summary>
protected const string BACKDROP_FILE = "backdrop.jpg";
/// <summary>
/// The Primary image
/// </summary>
protected const string PRIMARY_FILE = "folder.jpg";
2013-02-21 01:33:05 +00:00
/// <summary>
/// The API key
/// </summary>
protected const string APIKey = "5c6b04c68e904cfed1e6cbc9a9e683d4";
2013-03-04 05:43:06 +00:00
protected FanartBaseProvider(ILogManager logManager, IServerConfigurationManager configurationManager) : base(logManager, configurationManager)
2013-03-02 17:59:15 +00:00
{
}
2013-02-21 01:33:05 +00:00
/// <summary>
/// Needses the refresh internal.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="providerInfo">The provider info.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
{
if (item.DontFetchMeta) return false;
2013-03-04 05:43:06 +00:00
return DateTime.UtcNow > (providerInfo.LastRefreshed.AddDays(ConfigurationManager.Configuration.MetadataRefreshDays))
2013-02-21 01:33:05 +00:00
&& ShouldFetch(item, providerInfo);
}
/// <summary>
/// Gets a value indicating whether [requires internet].
/// </summary>
/// <value><c>true</c> if [requires internet]; otherwise, <c>false</c>.</value>
public override bool RequiresInternet
{
2013-03-04 14:34:00 +00:00
get { return true; }
2013-02-21 01:33:05 +00:00
}
/// <summary>
/// Gets the priority.
/// </summary>
/// <value>The priority.</value>
public override MetadataProviderPriority Priority
{
get { return MetadataProviderPriority.Third; }
}
/// <summary>
/// Shoulds the fetch.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="providerInfo">The provider info.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
protected virtual bool ShouldFetch(BaseItem item, BaseProviderInfo providerInfo)
{
return false;
}
2013-03-04 14:34:00 +00:00
#region Result Objects
protected class FanArtImageInfo
{
public string id { get; set; }
public string url { get; set; }
public string likes { get; set; }
}
protected class FanArtMusicInfo
{
public string mbid_id { get; set; }
public List<FanArtImageInfo> musiclogo { get; set; }
public List<FanArtImageInfo> artistbackground { get; set; }
public List<FanArtImageInfo> artistthumb { get; set; }
public List<FanArtImageInfo> hdmusiclogo { get; set; }
public List<FanArtImageInfo> musicbanner { get; set; }
}
protected class FanArtMusicResult
{
public FanArtMusicInfo result { get; set; }
}
#endregion
2013-02-21 01:33:05 +00:00
}
2013-03-04 14:34:00 +00:00
2013-02-21 01:33:05 +00:00
}