aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Entities/Video.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Controller/Entities/Video.cs')
-rw-r--r--MediaBrowser.Controller/Entities/Video.cs60
1 files changed, 60 insertions, 0 deletions
diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs
index 197222669..3b1da85b5 100644
--- a/MediaBrowser.Controller/Entities/Video.cs
+++ b/MediaBrowser.Controller/Entities/Video.cs
@@ -6,13 +6,16 @@ using MediaBrowser.Model.Entities;
using MediaBrowser.Model.MediaInfo;
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.IO;
using System.Linq;
+using System.Net.Mime;
using System.Runtime.Serialization;
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Common.IO;
+using MediaBrowser.Controller.Channels;
namespace MediaBrowser.Controller.Entities
{
@@ -33,6 +36,7 @@ namespace MediaBrowser.Controller.Entities
public List<string> AdditionalParts { get; set; }
public List<string> LocalAlternateVersions { get; set; }
public List<LinkedChild> LinkedAlternateVersions { get; set; }
+ public List<ChannelMediaInfo> ChannelMediaSources { get; set; }
[IgnoreDataMember]
public bool IsThemeMedia
@@ -79,6 +83,23 @@ namespace MediaBrowser.Controller.Entities
}
[IgnoreDataMember]
+ public override LocationType LocationType
+ {
+ get
+ {
+ if (SourceType == SourceType.Channel)
+ {
+ if (string.IsNullOrEmpty(Path))
+ {
+ return LocationType.Remote;
+ }
+ }
+
+ return base.LocationType;
+ }
+ }
+
+ [IgnoreDataMember]
public override bool SupportsAddingToPlaylist
{
get { return LocationType == LocationType.FileSystem && RunTimeTicks.HasValue; }
@@ -130,6 +151,29 @@ namespace MediaBrowser.Controller.Entities
return LocalAlternateVersions.Select(i => LibraryManager.GetNewItemId(i, typeof(Video)));
}
+ protected override string CreateUserDataKey()
+ {
+ if (ExtraType.HasValue)
+ {
+ var key = this.GetProviderId(MetadataProviders.Imdb) ?? this.GetProviderId(MetadataProviders.Tmdb);
+
+ if (!string.IsNullOrWhiteSpace(key))
+ {
+ key = key + "-" + ExtraType.ToString().ToLower();
+
+ // Make sure different trailers have their own data.
+ if (RunTimeTicks.HasValue)
+ {
+ key += "-" + RunTimeTicks.Value.ToString(CultureInfo.InvariantCulture);
+ }
+
+ return key;
+ }
+ }
+
+ return base.CreateUserDataKey();
+ }
+
/// <summary>
/// Gets the linked children.
/// </summary>
@@ -441,6 +485,22 @@ namespace MediaBrowser.Controller.Entities
public virtual IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
{
+ if (SourceType == SourceType.Channel)
+ {
+ var sources = ChannelManager.GetStaticMediaSources(this, false, CancellationToken.None)
+ .Result.ToList();
+
+ if (sources.Count > 0)
+ {
+ return sources;
+ }
+
+ return new List<MediaSourceInfo>
+ {
+ GetVersionInfo(enablePathSubstitution, this, MediaSourceType.Placeholder)
+ };
+ }
+
var item = this;
var result = item.GetAlternateVersions()