jellyfin-server/Emby.Server.Implementations/Channels/ChannelImageProvider.cs

56 lines
1.6 KiB
C#
Raw Normal View History

2014-03-18 17:05:57 +00:00
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Emby.Server.Implementations.Channels
2014-03-18 17:05:57 +00:00
{
2014-09-11 01:57:11 +00:00
public class ChannelImageProvider : IDynamicImageProvider, IHasItemChangeMonitor
2014-03-18 17:05:57 +00:00
{
private readonly IChannelManager _channelManager;
public ChannelImageProvider(IChannelManager channelManager)
{
_channelManager = channelManager;
}
2017-08-07 21:06:13 +00:00
public IEnumerable<ImageType> GetSupportedImages(IHasMetadata item)
2014-03-18 17:05:57 +00:00
{
return GetChannel(item).GetSupportedChannelImages();
}
2017-08-07 21:06:13 +00:00
public Task<DynamicImageResponse> GetImage(IHasMetadata item, ImageType type, CancellationToken cancellationToken)
2014-03-18 17:05:57 +00:00
{
var channel = GetChannel(item);
return channel.GetChannelImage(type, cancellationToken);
}
public string Name
{
get { return "Channel Image Provider"; }
}
2017-08-07 21:06:13 +00:00
public bool Supports(IHasMetadata item)
2014-03-18 17:05:57 +00:00
{
return item is Channel;
}
2017-08-07 21:06:13 +00:00
private IChannel GetChannel(IHasMetadata item)
2014-03-18 17:05:57 +00:00
{
var channel = (Channel)item;
return ((ChannelManager)_channelManager).GetChannelProvider(channel);
}
2014-09-11 01:57:11 +00:00
2016-04-08 18:32:38 +00:00
public bool HasChanged(IHasMetadata item, IDirectoryService directoryService)
2014-09-11 01:57:11 +00:00
{
return GetSupportedImages(item).Any(i => !item.HasImage(i));
}
2014-03-18 17:05:57 +00:00
}
}