The Free Software Media System - Server Backend & API
update DisplayParent
Luke Pulverenti2ec515027fe8
diff --git a/MediaBrowser.Controller/Channels/ChannelAudioItem.cs b/MediaBrowser.Controller/Channels/ChannelAudioItem.csdeleted file mode 100644index 41e9dd2033..0000000000--- a/MediaBrowser.Controller/Channels/ChannelAudioItem.cs+++ /dev/null@@ -1,101 +0,0 @@-using MediaBrowser.Controller.Entities;-using MediaBrowser.Controller.Entities.Audio;-using MediaBrowser.Model.Channels;-using MediaBrowser.Model.Configuration;-using MediaBrowser.Model.Dto;-using MediaBrowser.Model.Entities;-using System.Collections.Generic;-using System.Linq;-using System.Runtime.Serialization;-using System.Threading;--namespace MediaBrowser.Controller.Channels-{- public class ChannelAudioItem : Audio- {- public ChannelMediaContentType ContentType { get; set; }-- public List<ChannelMediaInfo> ChannelMediaSources { get; set; }-- public override UnratedItem GetBlockUnratedType()- {- return UnratedItem.ChannelContent;- }-- protected override string CreateUserDataKey()- {- return ExternalId;- }-- [IgnoreDataMember]- public override bool SupportsLocalMetadata- {- get- {- return false;- }- }-- public override bool IsSaveLocalMetadataEnabled()- {- return false;- }-- public ChannelAudioItem()- {- ChannelMediaSources = new List<ChannelMediaInfo>();- }-- [IgnoreDataMember]- public override LocationType LocationType- {- get- {- if (string.IsNullOrEmpty(Path))- {- return LocationType.Remote;- }-- return base.LocationType;- }- }-- protected override string GetInternalMetadataPath(string basePath)- {- return System.IO.Path.Combine(basePath, "channels", ChannelId, Id.ToString("N"));- }-- 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 override bool CanDelete()- {- return false;- }-- public override bool IsVisibleStandalone(User user)- {- return IsVisibleStandaloneInternal(user, false) && ChannelVideoItem.IsChannelVisible(this, user);- }- }-}diff --git a/MediaBrowser.Controller/Channels/ChannelFolderItem.cs b/MediaBrowser.Controller/Channels/ChannelFolderItem.csdeleted file mode 100644index 62e0d694e0..0000000000--- a/MediaBrowser.Controller/Channels/ChannelFolderItem.cs+++ /dev/null@@ -1,89 +0,0 @@-using MediaBrowser.Controller.Entities;-using MediaBrowser.Model.Channels;-using MediaBrowser.Model.Querying;-using MediaBrowser.Model.Users;-using System;-using System.Runtime.Serialization;-using System.Threading;-using System.Threading.Tasks;-using MediaBrowser.Model.Configuration;--namespace MediaBrowser.Controller.Channels-{- public class ChannelFolderItem : Folder- {- public ChannelFolderType ChannelFolderType { get; set; }-- protected override bool GetBlockUnratedValue(UserPolicy config)- {- // Don't block.- return false;- }-- public override UnratedItem GetBlockUnratedType()- {- return UnratedItem.ChannelContent;- }-- [IgnoreDataMember]- public override bool SupportsLocalMetadata- {- get- {- return false;- }- }-- public override bool IsSaveLocalMetadataEnabled()- {- return false;- }-- protected override string CreateUserDataKey()- {- return ExternalId;- }-- protected override async Task<QueryResult<BaseItem>> GetItemsInternal(InternalItemsQuery query)- {- try- {- // Don't blow up here because it could cause parent screens with other content to fail- return await ChannelManager.GetChannelItemsInternal(new ChannelItemQuery- {- ChannelId = ChannelId,- FolderId = Id.ToString("N"),- Limit = query.Limit,- StartIndex = query.StartIndex,- UserId = query.User.Id.ToString("N"),- SortBy = query.SortBy,- SortOrder = query.SortOrder-- }, new Progress<double>(), CancellationToken.None);- }- catch- {- // Already logged at lower levels- return new QueryResult<BaseItem>- {-- };- }- }-- 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) && ChannelVideoItem.IsChannelVisible(this, user);- }- }-}diff --git a/MediaBrowser.Controller/Channels/ChannelVideoItem.cs b/MediaBrowser.Controller/Channels/ChannelVideoItem.csdeleted file mode 100644index 9fe04812e0..0000000000--- a/MediaBrowser.Controller/Channels/ChannelVideoItem.cs+++ /dev/null@@ -1,126 +0,0 @@-using MediaBrowser.Controller.Entities;-using MediaBrowser.Model.Channels;-using MediaBrowser.Model.Configuration;-using MediaBrowser.Model.Dto;-using MediaBrowser.Model.Entities;-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- {- 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 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;- }-- 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) && IsChannelVisible(this, user);- }-- internal static bool IsChannelVisible(BaseItem item, User user)- {- var channel = ChannelManager.GetChannel(item.ChannelId);-- return channel.IsVisible(user);- }- }-}diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.csindex 29f416b8c6..26aae285de 100644--- a/MediaBrowser.Controller/Entities/BaseItem.cs+++ b/MediaBrowser.Controller/Entities/BaseItem.cs@@ -306,7 +306,7 @@ namespace MediaBrowser.Controller.Entities}}- private List<Tuple<StringBuilder,bool>> GetSortChunks(string s1)+ private List<Tuple<StringBuilder, bool>> GetSortChunks(string s1){var list = new List<Tuple<StringBuilder, bool>>();@@ -668,9 +668,30 @@ namespace MediaBrowser.Controller.Entities}[IgnoreDataMember]- public virtual BaseItem DisplayParent+ public virtual Guid? DisplayParentId{- get { return GetParent(); }+ get+ {+ if (ParentId == Guid.Empty)+ {+ return null;+ }+ return ParentId;+ }+ }++ [IgnoreDataMember]+ public BaseItem DisplayParent+ {+ get+ {+ var id = DisplayParentId;+ if (!id.HasValue)+ {+ return null;+ }+ return LibraryManager.GetItemById(id.Value);+ }}/// <summary>@@ -1454,7 +1475,7 @@ namespace MediaBrowser.Controller.Entitiespublic virtual string GetClientTypeName(){- if (IsFolder && SourceType == SourceType.Channel)+ if (IsFolder && SourceType == SourceType.Channel && !(this is Channel)){return "ChannelFolderItem";}diff --git a/MediaBrowser.Controller/Entities/IHasTrailers.cs b/MediaBrowser.Controller/Entities/IHasTrailers.csindex bc1c7d8758..e5cbdff723 100644--- a/MediaBrowser.Controller/Entities/IHasTrailers.cs+++ b/MediaBrowser.Controller/Entities/IHasTrailers.cs@@ -1,6 +1,7 @@using MediaBrowser.Model.Entities;using System;using System.Collections.Generic;+using System.Linq;namespace MediaBrowser.Controller.Entities{@@ -18,11 +19,20 @@ namespace MediaBrowser.Controller.Entities/// <value>The local trailer ids.</value>List<Guid> LocalTrailerIds { get; set; }List<Guid> RemoteTrailerIds { get; set; }+ }+ public static class HasTrailerExtensions+ {/// <summary>/// Gets the trailer ids./// </summary>/// <returns>List<Guid>.</returns>- List<Guid> GetTrailerIds();+ public static List<Guid> GetTrailerIds(this IHasTrailers item)+ {+ var list = item.LocalTrailerIds.ToList();+ list.AddRange(item.RemoteTrailerIds);+ return list;+ }+}}diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.csindex f5c2a9935a..4d2ca9ffea 100644--- a/MediaBrowser.Controller/Entities/Movies/Movie.cs+++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs@@ -78,17 +78,6 @@ namespace MediaBrowser.Controller.Entities.Moviesset { TmdbCollectionName = value; }}- /// <summary>- /// Gets the trailer ids.- /// </summary>- /// <returns>List<Guid>.</returns>- public List<Guid> GetTrailerIds()- {- var list = LocalTrailerIds.ToList();- list.AddRange(RemoteTrailerIds);- return list;- }-/// <summary>/// Gets the user data key./// </summary>diff --git a/MediaBrowser.Controller/Entities/TV/Episode.cs b/MediaBrowser.Controller/Entities/TV/Episode.csindex d016392e8e..ec65221bc9 100644--- a/MediaBrowser.Controller/Entities/TV/Episode.cs+++ b/MediaBrowser.Controller/Entities/TV/Episode.cs@@ -90,11 +90,11 @@ namespace MediaBrowser.Controller.Entities.TV}[IgnoreDataMember]- public override BaseItem DisplayParent+ public override Guid? DisplayParentId{get{- return Season ?? GetParent();+ return SeasonId;}}diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.csindex 5e067afd45..acd02e8ab9 100644--- a/MediaBrowser.Controller/Entities/TV/Season.cs+++ b/MediaBrowser.Controller/Entities/TV/Season.cs@@ -33,9 +33,13 @@ namespace MediaBrowser.Controller.Entities.TV}[IgnoreDataMember]- public override BaseItem DisplayParent+ public override Guid? DisplayParentId{- get { return Series ?? GetParent(); }+ get+ {+ var series = Series;+ return series == null ? ParentId : series.Id;+ }}// Genre, Rating and Stuido will all be the samediff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csprojindex 235638b5f1..6ff4e39e2d 100644--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj@@ -75,15 +75,12 @@</Compile><Compile Include="Activity\IActivityManager.cs" /><Compile Include="Activity\IActivityRepository.cs" />- <Compile Include="Channels\ChannelAudioItem.cs" />- <Compile Include="Channels\ChannelFolderItem.cs" /><Compile Include="Channels\ChannelItemInfo.cs" /><Compile Include="Channels\ChannelItemResult.cs" /><Compile Include="Channels\ChannelItemType.cs" /><Compile Include="Channels\ChannelMediaInfo.cs" /><Compile Include="Channels\ChannelParentalRating.cs" /><Compile Include="Channels\ChannelSearchInfo.cs" />- <Compile Include="Channels\ChannelVideoItem.cs" /><Compile Include="Channels\IChannel.cs" /><Compile Include="Channels\IChannelManager.cs" /><Compile Include="Channels\Channel.cs" />diff --git a/MediaBrowser.Dlna/Didl/DidlBuilder.cs b/MediaBrowser.Dlna/Didl/DidlBuilder.csindex ba42a06e25..89d00eb32b 100644--- a/MediaBrowser.Dlna/Didl/DidlBuilder.cs+++ b/MediaBrowser.Dlna/Didl/DidlBuilder.cs@@ -93,10 +93,10 @@ namespace MediaBrowser.Dlna.Didl}else{- var parent = item.DisplayParent;- if (parent != null)+ var parent = item.DisplayParentId;+ if (parent.HasValue){- element.SetAttribute("parentID", GetClientId(parent, null));+ element.SetAttribute("parentID", GetClientId(parent.Value, null));}}@@ -499,14 +499,21 @@ namespace MediaBrowser.Dlna.Didl{container.SetAttribute("id", clientId);- var parent = context ?? folder.DisplayParent;- if (parent == null)+ if (context != null){- container.SetAttribute("parentID", "0");+ container.SetAttribute("parentID", GetClientId(context, null));}else{- container.SetAttribute("parentID", GetClientId(parent, null));+ var parent = folder.DisplayParentId;+ if (!parent.HasValue)+ {+ container.SetAttribute("parentID", "0");+ }+ else+ {+ container.SetAttribute("parentID", GetClientId(parent.Value, null));+ }}}@@ -1059,7 +1066,12 @@ namespace MediaBrowser.Dlna.Didlpublic static string GetClientId(BaseItem item, StubType? stubType){- var id = item.Id.ToString("N");+ return GetClientId(item.Id, stubType);+ }++ public static string GetClientId(Guid idValue, StubType? stubType)+ {+ var id = idValue.ToString("N");if (stubType.HasValue){diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.csindex 234e15a66e..50ae195809 100644--- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs+++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs@@ -1149,10 +1149,10 @@ namespace MediaBrowser.Server.Implementations.Dtoif (fields.Contains(ItemFields.ParentId)){- var displayParent = item.DisplayParent;- if (displayParent != null)+ var displayParentId = item.DisplayParentId;+ if (displayParentId.HasValue){- dto.ParentId = GetDtoId(displayParent);+ dto.ParentId = displayParentId.Value.ToString("N");}}