2019-11-01 18:38:54 +01:00
|
|
|
#pragma warning disable CS1591
|
2019-12-11 00:13:57 +01:00
|
|
|
#pragma warning disable SA1600
|
2019-11-01 18:38:54 +01:00
|
|
|
|
2019-01-13 20:54:44 +01:00
|
|
|
using System.Collections.Generic;
|
2014-03-18 18:05:57 +01:00
|
|
|
using System.Linq;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Threading.Tasks;
|
2019-01-13 20:20:16 +01:00
|
|
|
using MediaBrowser.Controller.Channels;
|
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
using MediaBrowser.Controller.Providers;
|
|
|
|
using MediaBrowser.Model.Entities;
|
2014-03-18 18:05:57 +01:00
|
|
|
|
2016-11-02 21:53:50 +01:00
|
|
|
namespace Emby.Server.Implementations.Channels
|
2014-03-18 18:05:57 +01:00
|
|
|
{
|
2014-09-11 03:57:11 +02:00
|
|
|
public class ChannelImageProvider : IDynamicImageProvider, IHasItemChangeMonitor
|
2014-03-18 18:05:57 +01:00
|
|
|
{
|
|
|
|
private readonly IChannelManager _channelManager;
|
|
|
|
|
|
|
|
public ChannelImageProvider(IChannelManager channelManager)
|
|
|
|
{
|
|
|
|
_channelManager = channelManager;
|
|
|
|
}
|
|
|
|
|
2018-09-12 19:26:21 +02:00
|
|
|
public IEnumerable<ImageType> GetSupportedImages(BaseItem item)
|
2014-03-18 18:05:57 +01:00
|
|
|
{
|
|
|
|
return GetChannel(item).GetSupportedChannelImages();
|
|
|
|
}
|
|
|
|
|
2018-09-12 19:26:21 +02:00
|
|
|
public Task<DynamicImageResponse> GetImage(BaseItem item, ImageType type, CancellationToken cancellationToken)
|
2014-03-18 18:05:57 +01:00
|
|
|
{
|
|
|
|
var channel = GetChannel(item);
|
|
|
|
|
|
|
|
return channel.GetChannelImage(type, cancellationToken);
|
|
|
|
}
|
|
|
|
|
2019-01-06 21:50:43 +01:00
|
|
|
public string Name => "Channel Image Provider";
|
2014-03-18 18:05:57 +01:00
|
|
|
|
2018-09-12 19:26:21 +02:00
|
|
|
public bool Supports(BaseItem item)
|
2014-03-18 18:05:57 +01:00
|
|
|
{
|
|
|
|
return item is Channel;
|
|
|
|
}
|
|
|
|
|
2018-09-12 19:26:21 +02:00
|
|
|
private IChannel GetChannel(BaseItem item)
|
2014-03-18 18:05:57 +01:00
|
|
|
{
|
|
|
|
var channel = (Channel)item;
|
|
|
|
|
|
|
|
return ((ChannelManager)_channelManager).GetChannelProvider(channel);
|
|
|
|
}
|
2014-09-11 03:57:11 +02:00
|
|
|
|
2018-09-12 19:26:21 +02:00
|
|
|
public bool HasChanged(BaseItem item, IDirectoryService directoryService)
|
2014-09-11 03:57:11 +02:00
|
|
|
{
|
|
|
|
return GetSupportedImages(item).Any(i => !item.HasImage(i));
|
|
|
|
}
|
2014-03-18 18:05:57 +01:00
|
|
|
}
|
|
|
|
}
|