aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller
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
parent5dd77ab145553ea81b9faa6167a426b1ddcf1e9b (diff)
update channels
Diffstat (limited to 'MediaBrowser.Controller')
-rw-r--r--MediaBrowser.Controller/Channels/ChannelVideoItem.cs142
-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
-rw-r--r--MediaBrowser.Controller/MediaBrowser.Controller.csproj2
-rw-r--r--MediaBrowser.Controller/Providers/ChannelItemLookupInfo.cs11
7 files changed, 108 insertions, 155 deletions
diff --git a/MediaBrowser.Controller/Channels/ChannelVideoItem.cs b/MediaBrowser.Controller/Channels/ChannelVideoItem.cs
deleted file mode 100644
index c42363dcf..000000000
--- a/MediaBrowser.Controller/Channels/ChannelVideoItem.cs
+++ /dev/null
@@ -1,142 +0,0 @@
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Providers;
-using MediaBrowser.Model.Channels;
-using MediaBrowser.Model.Configuration;
-using MediaBrowser.Model.Dto;
-using MediaBrowser.Model.Entities;
-using MediaBrowser.Model.Users;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Runtime.Serialization;
-using System.Threading;
-
-namespace MediaBrowser.Controller.Channels
-{
- public class ChannelVideoItem : Video, IHasLookupInfo<ChannelItemLookupInfo>
- {
- public ChannelMediaContentType ContentType { get; set; }
-
- public List<ChannelMediaInfo> ChannelMediaSources { get; set; }
-
- protected override string CreateUserDataKey()
- {
- if (ContentType == ChannelMediaContentType.MovieExtra)
- {
- 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 ExternalId;
- }
-
- public override UnratedItem GetBlockUnratedType()
- {
- return UnratedItem.ChannelContent;
- }
-
- [IgnoreDataMember]
- public override SourceType SourceType
- {
- get { return SourceType.Channel; }
- set { }
- }
-
- [IgnoreDataMember]
- public override bool SupportsLocalMetadata
- {
- get
- {
- return false;
- }
- }
-
- public override bool IsSaveLocalMetadataEnabled()
- {
- return false;
- }
-
- public ChannelVideoItem()
- {
- ChannelMediaSources = new List<ChannelMediaInfo>();
- }
-
- [IgnoreDataMember]
- public override LocationType LocationType
- {
- get
- {
- if (string.IsNullOrEmpty(Path))
- {
- return LocationType.Remote;
- }
-
- return base.LocationType;
- }
- }
-
- public override IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
- {
- var sources = ChannelManager.GetStaticMediaSources(this, false, CancellationToken.None)
- .Result.ToList();
-
- if (sources.Count > 0)
- {
- return sources;
- }
-
- var list = base.GetMediaSources(enablePathSubstitution).ToList();
-
- foreach (var mediaSource in list)
- {
- if (string.IsNullOrWhiteSpace(mediaSource.Path))
- {
- mediaSource.Type = MediaSourceType.Placeholder;
- }
- }
-
- return list;
- }
-
- public ChannelItemLookupInfo GetLookupInfo()
- {
- var info = GetItemLookupInfo<ChannelItemLookupInfo>();
-
- info.ContentType = ContentType;
-
- if (ExtraType.HasValue)
- {
- info.ExtraType = ExtraType.Value;
- }
-
- return info;
- }
-
- protected override string GetInternalMetadataPath(string basePath)
- {
- return System.IO.Path.Combine(basePath, "channels", ChannelId, Id.ToString("N"));
- }
-
- public override bool CanDelete()
- {
- return false;
- }
-
- public override bool IsVisibleStandalone(User user)
- {
- return IsVisibleStandaloneInternal(user, false) && Channel.IsChannelVisible(this, user);
- }
- }
-}
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs
index 366aceb83..22f688c42 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 56f1e8a66..cedc9591d 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 3bff5bc64..cefc1dabe 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 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()
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index 7cc66ef73..572f45b36 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -83,7 +83,6 @@
<Compile Include="Channels\ChannelSearchInfo.cs" />
<Compile Include="Channels\IChannel.cs" />
<Compile Include="Channels\IChannelManager.cs" />
- <Compile Include="Channels\ChannelVideoItem.cs" />
<Compile Include="Channels\Channel.cs" />
<Compile Include="Channels\IHasCacheKey.cs" />
<Compile Include="Channels\IIndexableChannel.cs" />
@@ -268,7 +267,6 @@
<Compile Include="Providers\ArtistInfo.cs" />
<Compile Include="Providers\BookInfo.cs" />
<Compile Include="Providers\BoxSetInfo.cs" />
- <Compile Include="Providers\ChannelItemLookupInfo.cs" />
<Compile Include="Providers\DirectoryService.cs" />
<Compile Include="Providers\DynamicImageInfo.cs" />
<Compile Include="Providers\DynamicImageResponse.cs" />
diff --git a/MediaBrowser.Controller/Providers/ChannelItemLookupInfo.cs b/MediaBrowser.Controller/Providers/ChannelItemLookupInfo.cs
deleted file mode 100644
index 6c972f3bf..000000000
--- a/MediaBrowser.Controller/Providers/ChannelItemLookupInfo.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using MediaBrowser.Model.Channels;
-using MediaBrowser.Model.Entities;
-
-namespace MediaBrowser.Controller.Providers
-{
- public class ChannelItemLookupInfo : ItemLookupInfo
- {
- public ChannelMediaContentType ContentType { get; set; }
- public ExtraType ExtraType { get; set; }
- }
-} \ No newline at end of file