Răsfoiți Sursa

Merge pull request #1640 from MediaBrowser/dev

Dev
Luke 9 ani în urmă
părinte
comite
4346b53679

+ 0 - 101
MediaBrowser.Controller/Channels/ChannelAudioItem.cs

@@ -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);
-        }
-    }
-}

+ 0 - 89
MediaBrowser.Controller/Channels/ChannelFolderItem.cs

@@ -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);
-        }
-    }
-}

+ 0 - 126
MediaBrowser.Controller/Channels/ChannelVideoItem.cs

@@ -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);
-        }
-    }
-}

+ 25 - 4
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.Entities
 
         public virtual string GetClientTypeName()
         {
-            if (IsFolder && SourceType == SourceType.Channel)
+            if (IsFolder && SourceType == SourceType.Channel && !(this is Channel))
             {
                 return "ChannelFolderItem";
             }

+ 11 - 1
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&lt;Guid&gt;.</returns>
-        List<Guid> GetTrailerIds();
+        public static List<Guid> GetTrailerIds(this IHasTrailers item)
+        {
+            var list = item.LocalTrailerIds.ToList();
+            list.AddRange(item.RemoteTrailerIds);
+            return list;
+        }
+
     }
 }

+ 0 - 11
MediaBrowser.Controller/Entities/Movies/Movie.cs

@@ -78,17 +78,6 @@ namespace MediaBrowser.Controller.Entities.Movies
             set { TmdbCollectionName = value; }
         }
         
-        /// <summary>
-        /// Gets the trailer ids.
-        /// </summary>
-        /// <returns>List&lt;Guid&gt;.</returns>
-        public List<Guid> GetTrailerIds()
-        {
-            var list = LocalTrailerIds.ToList();
-            list.AddRange(RemoteTrailerIds);
-            return list;
-        }
-
         /// <summary>
         /// Gets the user data key.
         /// </summary>

+ 2 - 2
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;
             }
         }
 

+ 6 - 2
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 same

+ 0 - 3
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" />

+ 20 - 8
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.Didl
 
         public 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)
             {

+ 3 - 3
MediaBrowser.Server.Implementations/Dto/DtoService.cs

@@ -1149,10 +1149,10 @@ namespace MediaBrowser.Server.Implementations.Dto
 
             if (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");
                 }
             }
 

+ 1 - 1
MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs

@@ -251,7 +251,7 @@ namespace MediaBrowser.Server.Implementations.IO
         /// <exception cref="System.ArgumentNullException">path</exception>
         private static bool ContainsParentFolder(IEnumerable<string> lst, string path)
         {
-            if (string.IsNullOrEmpty(path))
+            if (string.IsNullOrWhiteSpace(path))
             {
                 throw new ArgumentNullException("path");
             }

+ 1 - 0
MediaBrowser.WebDashboard/Api/PackageCreator.cs

@@ -415,6 +415,7 @@ namespace MediaBrowser.WebDashboard.Api
             sb.Append("<link rel=\"shortcut icon\" href=\"css/images/favicon.ico\">");
             sb.Append("<meta name=\"msapplication-TileImage\" content=\"css/images/touchicon144.png\">");
             sb.Append("<meta name=\"msapplication-TileColor\" content=\"#333333\">");
+            sb.Append("<meta name=\"theme-color\" content=\"#43A047\">");
 
             return sb.ToString();
         }

+ 2 - 2
Nuget/MediaBrowser.Common.Internal.nuspec

@@ -2,7 +2,7 @@
 <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
     <metadata>
         <id>MediaBrowser.Common.Internal</id>
-        <version>3.0.644</version>
+        <version>3.0.645</version>
         <title>MediaBrowser.Common.Internal</title>
         <authors>Luke</authors>
         <owners>ebr,Luke,scottisafool</owners>
@@ -12,7 +12,7 @@
         <description>Contains common components shared by Emby Theater and Emby Server. Not intended for plugin developer consumption.</description>
         <copyright>Copyright © Emby 2013</copyright>
         <dependencies>
-            <dependency id="MediaBrowser.Common" version="3.0.644" />
+            <dependency id="MediaBrowser.Common" version="3.0.645" />
             <dependency id="NLog" version="4.2.3" />
             <dependency id="SimpleInjector" version="3.1.2" />
         </dependencies>

+ 1 - 1
Nuget/MediaBrowser.Common.nuspec

@@ -2,7 +2,7 @@
 <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
     <metadata>
         <id>MediaBrowser.Common</id>
-        <version>3.0.644</version>
+        <version>3.0.645</version>
         <title>MediaBrowser.Common</title>
         <authors>Emby Team</authors>
         <owners>ebr,Luke,scottisafool</owners>

+ 1 - 1
Nuget/MediaBrowser.Model.Signed.nuspec

@@ -2,7 +2,7 @@
 <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
     <metadata>
         <id>MediaBrowser.Model.Signed</id>
-        <version>3.0.644</version>
+        <version>3.0.645</version>
         <title>MediaBrowser.Model - Signed Edition</title>
         <authors>Emby Team</authors>
         <owners>ebr,Luke,scottisafool</owners>

+ 2 - 2
Nuget/MediaBrowser.Server.Core.nuspec

@@ -2,7 +2,7 @@
 <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
     <metadata>
         <id>MediaBrowser.Server.Core</id>
-        <version>3.0.644</version>
+        <version>3.0.645</version>
         <title>Media Browser.Server.Core</title>
         <authors>Emby Team</authors>
         <owners>ebr,Luke,scottisafool</owners>
@@ -12,7 +12,7 @@
         <description>Contains core components required to build plugins for Emby Server.</description>
         <copyright>Copyright © Emby 2013</copyright>
         <dependencies>
-            <dependency id="MediaBrowser.Common" version="3.0.644" />
+            <dependency id="MediaBrowser.Common" version="3.0.645" />
 			<dependency id="Interfaces.IO" version="1.0.0.5" />
         </dependencies>
     </metadata>