2014-03-17 21:45:41 -04:00
|
|
|
|
using MediaBrowser.Controller.Entities;
|
2014-09-22 17:56:54 -04:00
|
|
|
|
using MediaBrowser.Controller.Providers;
|
2014-05-19 15:51:56 -04:00
|
|
|
|
using MediaBrowser.Model.Channels;
|
2014-05-03 00:20:04 -04:00
|
|
|
|
using MediaBrowser.Model.Configuration;
|
2014-06-02 22:01:30 -04:00
|
|
|
|
using MediaBrowser.Model.Dto;
|
2014-05-03 00:20:04 -04:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
2015-02-06 00:39:07 -05:00
|
|
|
|
using MediaBrowser.Model.Users;
|
2014-05-18 15:58:42 -04:00
|
|
|
|
using System.Collections.Generic;
|
2014-05-03 00:20:04 -04:00
|
|
|
|
using System.Globalization;
|
|
|
|
|
|
using System.Linq;
|
2015-10-04 14:10:50 -04:00
|
|
|
|
using System.Runtime.Serialization;
|
2014-10-07 21:37:45 -04:00
|
|
|
|
using System.Threading;
|
2014-03-17 21:45:41 -04:00
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Channels
|
|
|
|
|
|
{
|
2014-09-22 17:56:54 -04:00
|
|
|
|
public class ChannelVideoItem : Video, IChannelMediaItem, IHasLookupInfo<ChannelItemLookupInfo>
|
2014-03-17 21:45:41 -04:00
|
|
|
|
{
|
|
|
|
|
|
public ChannelItemType ChannelItemType { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public ChannelMediaContentType ContentType { get; set; }
|
|
|
|
|
|
|
2014-05-18 15:58:42 -04:00
|
|
|
|
public List<ChannelMediaInfo> ChannelMediaSources { get; set; }
|
2015-01-24 17:33:26 -05:00
|
|
|
|
|
|
|
|
|
|
protected override string CreateUserDataKey()
|
2014-05-03 00:20:04 -04:00
|
|
|
|
{
|
2014-09-28 11:27:26 -04:00
|
|
|
|
if (ContentType == ChannelMediaContentType.MovieExtra)
|
2014-05-03 00:20:04 -04:00
|
|
|
|
{
|
2014-09-28 16:49:43 -04:00
|
|
|
|
var key = this.GetProviderId(MetadataProviders.Imdb) ?? this.GetProviderId(MetadataProviders.Tmdb);
|
2014-05-03 00:20:04 -04:00
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(key))
|
|
|
|
|
|
{
|
2014-09-28 11:27:26 -04:00
|
|
|
|
key = key + "-" + ExtraType.ToString().ToLower();
|
2014-05-03 00:20:04 -04:00
|
|
|
|
|
|
|
|
|
|
// Make sure different trailers have their own data.
|
|
|
|
|
|
if (RunTimeTicks.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
key += "-" + RunTimeTicks.Value.ToString(CultureInfo.InvariantCulture);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return key;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-06-02 15:32:41 -04:00
|
|
|
|
return ExternalId;
|
2014-05-03 00:20:04 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2014-12-20 01:06:27 -05:00
|
|
|
|
protected override bool GetBlockUnratedValue(UserPolicy config)
|
2014-05-03 00:20:04 -04:00
|
|
|
|
{
|
|
|
|
|
|
return config.BlockUnratedItems.Contains(UnratedItem.ChannelContent);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-10-04 14:10:50 -04:00
|
|
|
|
[IgnoreDataMember]
|
2014-05-03 00:20:04 -04:00
|
|
|
|
public override bool SupportsLocalMetadata
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2014-05-18 15:58:42 -04:00
|
|
|
|
|
2014-09-28 11:27:26 -04:00
|
|
|
|
public override bool IsSaveLocalMetadataEnabled()
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-05-18 15:58:42 -04:00
|
|
|
|
public ChannelVideoItem()
|
|
|
|
|
|
{
|
|
|
|
|
|
ChannelMediaSources = new List<ChannelMediaInfo>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-10-04 14:10:50 -04:00
|
|
|
|
[IgnoreDataMember]
|
2014-05-18 15:58:42 -04:00
|
|
|
|
public override LocationType LocationType
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(Path))
|
|
|
|
|
|
{
|
|
|
|
|
|
return LocationType.Remote;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return base.LocationType;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2014-06-02 22:01:30 -04:00
|
|
|
|
|
|
|
|
|
|
public override IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
|
|
|
|
|
|
{
|
2015-03-28 16:22:27 -04:00
|
|
|
|
var sources = ChannelManager.GetStaticMediaSources(this, false, CancellationToken.None)
|
|
|
|
|
|
.Result.ToList();
|
2014-10-07 21:37:45 -04:00
|
|
|
|
|
|
|
|
|
|
if (sources.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
return sources;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-03-28 16:22:27 -04:00
|
|
|
|
var list = base.GetMediaSources(enablePathSubstitution).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var mediaSource in list)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(mediaSource.Path))
|
|
|
|
|
|
{
|
|
|
|
|
|
mediaSource.Type = MediaSourceType.Placeholder;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2014-06-02 22:01:30 -04:00
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
|
}
|
2014-09-22 17:56:54 -04:00
|
|
|
|
|
|
|
|
|
|
public ChannelItemLookupInfo GetLookupInfo()
|
|
|
|
|
|
{
|
|
|
|
|
|
var info = GetItemLookupInfo<ChannelItemLookupInfo>();
|
|
|
|
|
|
|
|
|
|
|
|
info.ContentType = ContentType;
|
2015-09-19 22:06:56 -04:00
|
|
|
|
|
|
|
|
|
|
if (ExtraType.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
info.ExtraType = ExtraType.Value;
|
|
|
|
|
|
}
|
2014-09-22 17:56:54 -04:00
|
|
|
|
|
|
|
|
|
|
return info;
|
|
|
|
|
|
}
|
2014-09-28 11:27:26 -04:00
|
|
|
|
|
|
|
|
|
|
protected override string GetInternalMetadataPath(string basePath)
|
|
|
|
|
|
{
|
|
|
|
|
|
return System.IO.Path.Combine(basePath, "channels", ChannelId, Id.ToString("N"));
|
|
|
|
|
|
}
|
2015-02-06 00:39:07 -05:00
|
|
|
|
|
|
|
|
|
|
public override bool CanDelete()
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2015-04-05 23:47:01 -04:00
|
|
|
|
|
|
|
|
|
|
public override bool IsVisibleStandalone(User user)
|
|
|
|
|
|
{
|
2015-04-10 10:49:03 -04:00
|
|
|
|
return IsVisibleStandaloneInternal(user, false) && IsChannelVisible(this, user);
|
2015-04-05 23:47:01 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
internal static bool IsChannelVisible(IChannelItem item, User user)
|
|
|
|
|
|
{
|
|
|
|
|
|
var channel = ChannelManager.GetChannel(item.ChannelId);
|
|
|
|
|
|
|
|
|
|
|
|
return channel.IsVisible(user);
|
|
|
|
|
|
}
|
2014-03-17 21:45:41 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|