aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Entities
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2016-03-19 11:38:05 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2016-03-19 11:38:05 -0400
commit1d2b6329bf3d395c57ac45a0f56b2e15bbee4c22 (patch)
treed1938509e92eac1b2f8ac9f5657785a155a05d50 /MediaBrowser.Controller/Entities
parent5dd77ab145553ea81b9faa6167a426b1ddcf1e9b (diff)
update channels
Diffstat (limited to 'MediaBrowser.Controller/Entities')
-rw-r--r--MediaBrowser.Controller/Entities/BaseItem.cs5
-rw-r--r--MediaBrowser.Controller/Entities/InternalItemsQuery.cs2
-rw-r--r--MediaBrowser.Controller/Entities/Trailer.cs41
-rw-r--r--MediaBrowser.Controller/Entities/Video.cs60
4 files changed, 108 insertions, 0 deletions
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs
index 366aceb835..22f688c424 100644
--- a/MediaBrowser.Controller/Entities/BaseItem.cs
+++ b/MediaBrowser.Controller/Entities/BaseItem.cs
@@ -1359,6 +1359,11 @@ namespace MediaBrowser.Controller.Entities
public virtual string GetClientTypeName()
{
+ if (IsFolder && SourceType == SourceType.Channel)
+ {
+ return "ChannelFolderItem";
+ }
+
return GetType().Name;
}
diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs
index 56f1e8a66f..cedc9591d5 100644
--- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs
+++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs
@@ -116,6 +116,7 @@ namespace MediaBrowser.Controller.Entities
public LocationType[] ExcludeLocationTypes { get; set; }
public string[] PresetViews { get; set; }
public SourceType[] SourceTypes { get; set; }
+ public SourceType[] ExcludeSourceTypes { get; set; }
public InternalItemsQuery()
{
@@ -143,6 +144,7 @@ namespace MediaBrowser.Controller.Entities
ExcludeLocationTypes = new LocationType[] { };
PresetViews = new string[] { };
SourceTypes = new SourceType[] { };
+ ExcludeSourceTypes = new SourceType[] { };
}
public InternalItemsQuery(User user)
diff --git a/MediaBrowser.Controller/Entities/Trailer.cs b/MediaBrowser.Controller/Entities/Trailer.cs
index 3bff5bc64f..cefc1dabe9 100644
--- a/MediaBrowser.Controller/Entities/Trailer.cs
+++ b/MediaBrowser.Controller/Entities/Trailer.cs
@@ -106,8 +106,49 @@ namespace MediaBrowser.Controller.Entities
var info = GetItemLookupInfo<TrailerInfo>();
info.IsLocalTrailer = IsLocalTrailer;
+
+ if (!IsInMixedFolder)
+ {
+ info.Name = System.IO.Path.GetFileName(ContainingFolderPath);
+ }
return info;
}
+
+ public override bool BeforeMetadataRefresh()
+ {
+ var hasChanges = base.BeforeMetadataRefresh();
+
+ if (!ProductionYear.HasValue)
+ {
+ var info = LibraryManager.ParseName(Name);
+
+ var yearInName = info.Year;
+
+ if (yearInName.HasValue)
+ {
+ ProductionYear = yearInName;
+ hasChanges = true;
+ }
+ else
+ {
+ // Try to get the year from the folder name
+ if (!IsInMixedFolder)
+ {
+ info = LibraryManager.ParseName(System.IO.Path.GetFileName(ContainingFolderPath));
+
+ yearInName = info.Year;
+
+ if (yearInName.HasValue)
+ {
+ ProductionYear = yearInName;
+ hasChanges = true;
+ }
+ }
+ }
+ }
+
+ return hasChanges;
+ }
}
}
diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs
index 1972226692..3b1da85b55 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()