jellyfin/MediaBrowser.Controller/Channels/ChannelVideoItem.cs

123 lines
3.4 KiB
C#
Raw Normal View History

2014-03-18 02:45:41 +01:00
using MediaBrowser.Controller.Entities;
2014-09-22 23:56:54 +02:00
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Channels;
2014-05-03 06:20:04 +02:00
using MediaBrowser.Model.Configuration;
2014-06-03 04:01:30 +02:00
using MediaBrowser.Model.Dto;
2014-05-03 06:20:04 +02:00
using MediaBrowser.Model.Entities;
2014-05-18 21:58:42 +02:00
using System.Collections.Generic;
2014-05-03 06:20:04 +02:00
using System.Globalization;
using System.Linq;
2014-10-08 03:37:45 +02:00
using System.Threading;
2014-03-18 02:45:41 +01:00
namespace MediaBrowser.Controller.Channels
{
2014-09-22 23:56:54 +02:00
public class ChannelVideoItem : Video, IChannelMediaItem, IHasLookupInfo<ChannelItemLookupInfo>
2014-03-18 02:45:41 +01:00
{
public string ExternalId { get; set; }
2014-05-05 02:46:52 +02:00
public string ChannelId { get; set; }
2014-09-28 17:27:26 +02:00
public string DataVersion { get; set; }
2014-03-18 02:45:41 +01:00
public ChannelItemType ChannelItemType { get; set; }
public bool IsInfiniteStream { get; set; }
public ChannelMediaContentType ContentType { get; set; }
public string OriginalImageUrl { get; set; }
2014-05-03 06:20:04 +02:00
2014-05-18 21:58:42 +02:00
public List<ChannelMediaInfo> ChannelMediaSources { get; set; }
2014-05-03 06:20:04 +02:00
public override string GetUserDataKey()
{
2014-09-28 17:27:26 +02:00
if (ContentType == ChannelMediaContentType.MovieExtra)
2014-05-03 06:20:04 +02:00
{
2014-09-28 22:49:43 +02:00
var key = this.GetProviderId(MetadataProviders.Imdb) ?? this.GetProviderId(MetadataProviders.Tmdb);
2014-05-03 06:20:04 +02:00
if (!string.IsNullOrWhiteSpace(key))
{
2014-09-28 17:27:26 +02:00
key = key + "-" + ExtraType.ToString().ToLower();
2014-05-03 06:20:04 +02:00
// Make sure different trailers have their own data.
if (RunTimeTicks.HasValue)
{
key += "-" + RunTimeTicks.Value.ToString(CultureInfo.InvariantCulture);
}
return key;
}
}
2014-06-02 21:32:41 +02:00
return ExternalId;
2014-05-03 06:20:04 +02:00
}
protected override bool GetBlockUnratedValue(UserConfiguration config)
{
return config.BlockUnratedItems.Contains(UnratedItem.ChannelContent);
}
public override bool SupportsLocalMetadata
{
get
{
return false;
}
}
2014-05-18 21:58:42 +02:00
2014-09-28 17:27:26 +02:00
public override bool IsSaveLocalMetadataEnabled()
{
return false;
}
2014-05-18 21:58:42 +02:00
public ChannelVideoItem()
{
ChannelMediaSources = new List<ChannelMediaInfo>();
}
public override LocationType LocationType
{
get
{
if (string.IsNullOrEmpty(Path))
{
return LocationType.Remote;
}
return base.LocationType;
}
}
2014-06-03 04:01:30 +02:00
public override IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
{
var list = base.GetMediaSources(enablePathSubstitution).ToList();
2014-10-08 03:37:45 +02:00
var sources = ChannelManager.GetChannelItemMediaSources(Id.ToString("N"), false, CancellationToken.None)
.Result.ToList();
if (sources.Count > 0)
{
return sources;
}
list.InsertRange(0, sources);
2014-06-03 04:01:30 +02:00
return list;
}
2014-09-22 23:56:54 +02:00
public ChannelItemLookupInfo GetLookupInfo()
{
var info = GetItemLookupInfo<ChannelItemLookupInfo>();
info.ContentType = ContentType;
2014-09-28 17:27:26 +02:00
info.ExtraType = ExtraType;
2014-09-22 23:56:54 +02:00
return info;
}
2014-09-28 17:27:26 +02:00
protected override string GetInternalMetadataPath(string basePath)
{
return System.IO.Path.Combine(basePath, "channels", ChannelId, Id.ToString("N"));
}
2014-03-18 02:45:41 +01:00
}
}