Bladeren bron

add additional view settings

Luke Pulverenti 11 jaren geleden
bovenliggende
commit
43943657b7

+ 7 - 0
MediaBrowser.Controller/Collections/ICollectionManager.cs

@@ -38,5 +38,12 @@ namespace MediaBrowser.Controller.Collections
         /// <param name="user">The user.</param>
         /// <returns>IEnumerable{BaseItem}.</returns>
         IEnumerable<BaseItem> CollapseItemsWithinBoxSets(IEnumerable<BaseItem> items, User user);
+
+        /// <summary>
+        /// Gets the collections folder.
+        /// </summary>
+        /// <param name="userId">The user identifier.</param>
+        /// <returns>Folder.</returns>
+        Folder GetCollectionsFolder(string userId);
     }
 }

+ 5 - 0
MediaBrowser.Controller/Entities/BaseItem.cs

@@ -134,6 +134,11 @@ namespace MediaBrowser.Controller.Entities
             }
         }
 
+        public virtual bool IsHiddenFromUser(User user)
+        {
+            return false;
+        }
+
         [IgnoreDataMember]
         public virtual bool IsOwnedItem
         {

+ 4 - 1
MediaBrowser.Controller/Entities/Folder.cs

@@ -809,7 +809,10 @@ namespace MediaBrowser.Controller.Entities
                 {
                     if (filter == null || filter(child))
                     {
-                        list.Add(child);
+                        if (!child.IsHiddenFromUser(user))
+                        {
+                            list.Add(child);
+                        }
                     }
 
                     if (recursive && child.IsFolder)

+ 4 - 6
MediaBrowser.Model/Configuration/NotificationOptions.cs

@@ -1,6 +1,4 @@
-using System;
-using System.Linq;
-using MediaBrowser.Model.Extensions;
+using MediaBrowser.Model.Extensions;
 
 namespace MediaBrowser.Model.Configuration
 {
@@ -90,7 +88,7 @@ namespace MediaBrowser.Model.Configuration
             NotificationOption opt = GetOptions(notificationType);
 
             return opt == null ||
-                   !opt.DisabledServices.Contains(service, StringComparer.OrdinalIgnoreCase);
+                   !ListHelper.ContainsIgnoreCase(opt.DisabledServices, service);
         }
 
         public bool IsEnabledToMonitorUser(string type, string userId)
@@ -98,7 +96,7 @@ namespace MediaBrowser.Model.Configuration
             NotificationOption opt = GetOptions(type);
 
             return opt != null && opt.Enabled &&
-                   !opt.DisabledMonitorUsers.Contains(userId, StringComparer.OrdinalIgnoreCase);
+                   !ListHelper.ContainsIgnoreCase(opt.DisabledMonitorUsers, userId);
         }
 
         public bool IsEnabledToSendToUser(string type, string userId, UserConfiguration userConfig)
@@ -117,7 +115,7 @@ namespace MediaBrowser.Model.Configuration
                     return true;
                 }
 
-                return opt.SendToUsers.Contains(userId, StringComparer.OrdinalIgnoreCase);
+                return ListHelper.ContainsIgnoreCase(opt.SendToUsers, userId);
             }
 
             return false;

+ 3 - 0
MediaBrowser.Model/Configuration/UserConfiguration.cs

@@ -72,6 +72,7 @@ namespace MediaBrowser.Model.Configuration
         public UnratedItem[] BlockUnratedItems { get; set; }
 
         public SubtitlePlaybackMode SubtitleMode { get; set; }
+        public bool DisplayCollectionsView { get; set; }
 
         /// <summary>
         /// Initializes a new instance of the <see cref="UserConfiguration" /> class.
@@ -92,6 +93,8 @@ namespace MediaBrowser.Model.Configuration
             BlockUnratedItems = new UnratedItem[] { };
 
             ExcludeFoldersFromGrouping = new string[] { };
+
+            DisplayCollectionsView = true;
         }
     }
 }

+ 5 - 5
MediaBrowser.Model/Dlna/DeviceProfile.cs

@@ -115,7 +115,7 @@ namespace MediaBrowser.Model.Dlna
 
         public TranscodingProfile GetAudioTranscodingProfile(string container, string audioCodec)
         {
-            container = (container ?? string.Empty).TrimStart('.');
+            container = StringHelper.TrimStart((container ?? string.Empty), '.');
 
             foreach (var i in TranscodingProfiles)
             {
@@ -141,7 +141,7 @@ namespace MediaBrowser.Model.Dlna
 
         public TranscodingProfile GetVideoTranscodingProfile(string container, string audioCodec, string videoCodec)
         {
-            container = (container ?? string.Empty).TrimStart('.');
+            container = StringHelper.TrimStart((container ?? string.Empty), '.');
 
             foreach (var i in TranscodingProfiles)
             {
@@ -172,7 +172,7 @@ namespace MediaBrowser.Model.Dlna
 
         public ResponseProfile GetAudioMediaProfile(string container, string audioCodec, int? audioChannels, int? audioBitrate)
         {
-            container = (container ?? string.Empty).TrimStart('.');
+            container = StringHelper.TrimStart((container ?? string.Empty), '.');
 
             foreach (var i in ResponseProfiles)
             {
@@ -217,7 +217,7 @@ namespace MediaBrowser.Model.Dlna
 
         public ResponseProfile GetImageMediaProfile(string container, int? width, int? height)
         {
-            container = (container ?? string.Empty).TrimStart('.');
+            container = StringHelper.TrimStart((container ?? string.Empty), '.');
 
             foreach (var i in ResponseProfiles)
             {
@@ -270,7 +270,7 @@ namespace MediaBrowser.Model.Dlna
             TransportStreamTimestamp timestamp,
             bool? isAnamorphic)
         {
-            container = (container ?? string.Empty).TrimStart('.');
+            container = StringHelper.TrimStart((container ?? string.Empty), '.');
 
             foreach (var i in ResponseProfiles)
             {

+ 36 - 7
MediaBrowser.Model/Dlna/StreamBuilder.cs

@@ -136,7 +136,12 @@ namespace MediaBrowser.Model.Dlna
                         foreach (CodecProfile i in options.Profile.CodecProfiles)
                         {
                             if (i.Type == CodecType.Audio && i.ContainsCodec(audioCodec))
-                                conditions.AddRange(i.Conditions);
+                            {
+                                foreach (var c in i.Conditions)
+                                {
+                                    conditions.Add(c);
+                                }
+                            }
                         }
 
                         int? audioChannels = audioStream.Channels;
@@ -195,7 +200,12 @@ namespace MediaBrowser.Model.Dlna
 
                 List<ProfileCondition> audioTranscodingConditions = new List<ProfileCondition>();
                 foreach (CodecProfile i in audioCodecProfiles)
-                        audioTranscodingConditions.AddRange(i.Conditions);
+                {
+                    foreach (var c in i.Conditions)
+                    {
+                        audioTranscodingConditions.Add(c);
+                    }
+                }
 
                 ApplyTranscodingConditions(playlistItem, audioTranscodingConditions);
 
@@ -276,7 +286,10 @@ namespace MediaBrowser.Model.Dlna
                 {
                     if (i.Type == CodecType.Video && i.ContainsCodec(transcodingProfile.VideoCodec))
                     {
-                        videoTranscodingConditions.AddRange(i.Conditions);
+                        foreach (var c in i.Conditions)
+                        {
+                            videoTranscodingConditions.Add(c);
+                        }
                         break;
                     }
                 }
@@ -287,7 +300,10 @@ namespace MediaBrowser.Model.Dlna
                 {
                     if (i.Type == CodecType.VideoAudio && i.ContainsCodec(transcodingProfile.AudioCodec))
                     {
-                        audioTranscodingConditions.AddRange(i.Conditions);
+                        foreach (var c in i.Conditions)
+                        {
+                            audioTranscodingConditions.Add(c);
+                        }
                         break;
                     }
                 }
@@ -363,7 +379,10 @@ namespace MediaBrowser.Model.Dlna
                 if (i.Type == DlnaProfileType.Video &&
                     ListHelper.ContainsIgnoreCase(i.GetContainers(), container))
                 {
-                    conditions.AddRange(i.Conditions);
+                    foreach (var c in i.Conditions)
+                    {
+                        conditions.Add(c);
+                    }
                 }
             }
 
@@ -405,7 +424,12 @@ namespace MediaBrowser.Model.Dlna
             foreach (CodecProfile i in profile.CodecProfiles)
             {
                 if (i.Type == CodecType.Video && i.ContainsCodec(videoCodec))
-                    conditions.AddRange(i.Conditions);
+                {
+                    foreach (var c in i.Conditions)
+                    {
+                        conditions.Add(c);
+                    }
+                }
             }
 
             foreach (ProfileCondition i in conditions)
@@ -429,7 +453,12 @@ namespace MediaBrowser.Model.Dlna
                 foreach (CodecProfile i in profile.CodecProfiles)
                 {
                     if (i.Type == CodecType.VideoAudio && i.ContainsCodec(audioCodec))
-                        conditions.AddRange(i.Conditions);
+                    {
+                        foreach (var c in i.Conditions)
+                        {
+                            conditions.Add(c);
+                        }
+                    }
                 }
 
                 foreach (ProfileCondition i in conditions)

+ 17 - 5
MediaBrowser.Model/Dlna/StreamInfo.cs

@@ -305,8 +305,14 @@ namespace MediaBrowser.Model.Dlna
                 {
                     int? totalBitrate = TargetTotalBitrate;
 
+                    double totalSeconds = RunTimeTicks.Value;
+                    // Convert to ms
+                    totalSeconds /= 10000;
+                    // Convert to seconds
+                    totalSeconds /= 1000;
+
                     return totalBitrate.HasValue ?
-                        Convert.ToInt64(totalBitrate.Value * TimeSpan.FromTicks(RunTimeTicks.Value).TotalSeconds) :
+                        Convert.ToInt64(totalBitrate.Value * totalSeconds) :
                         (long?)null;
                 }
 
@@ -375,11 +381,14 @@ namespace MediaBrowser.Model.Dlna
                         Height = videoStream.Height.Value
                     };
 
+                    double? maxWidth = MaxWidth.HasValue ? (double)MaxWidth.Value : (double?)null;
+                    double? maxHeight = MaxHeight.HasValue ? (double)MaxHeight.Value : (double?)null;
+
                     ImageSize newSize = DrawingUtils.Resize(size,
                         null,
                         null,
-                        MaxWidth,
-                        MaxHeight);
+                        maxWidth,
+                        maxHeight);
 
                     return Convert.ToInt32(newSize.Width);
                 }
@@ -402,11 +411,14 @@ namespace MediaBrowser.Model.Dlna
                         Height = videoStream.Height.Value
                     };
 
+                    double? maxWidth = MaxWidth.HasValue ? (double)MaxWidth.Value : (double?)null;
+                    double? maxHeight = MaxHeight.HasValue ? (double)MaxHeight.Value : (double?)null;
+
                     ImageSize newSize = DrawingUtils.Resize(size,
                         null,
                         null,
-                        MaxWidth,
-                        MaxHeight);
+                        maxWidth,
+                        maxHeight);
 
                     return Convert.ToInt32(newSize.Height);
                 }

+ 11 - 0
MediaBrowser.Model/Extensions/StringHelper.cs

@@ -59,5 +59,16 @@ namespace MediaBrowser.Model.Extensions
         {
             return val.ToString(CultureInfo.InvariantCulture);
         }
+
+        /// <summary>
+        /// Trims the start.
+        /// </summary>
+        /// <param name="str">The string.</param>
+        /// <param name="c">The c.</param>
+        /// <returns>System.String.</returns>
+        public static string TrimStart(string str, char c)
+        {
+            return str.TrimStart(c);
+        }
     }
 }

+ 0 - 5
MediaBrowser.Model/Notifications/Notification.cs

@@ -19,10 +19,5 @@ namespace MediaBrowser.Model.Notifications
         public string Url { get; set; }
 
         public NotificationLevel Level { get; set; }
-
-        public Notification()
-        {
-            Date = DateTime.UtcNow;
-        }
     }
 }

+ 8 - 3
MediaBrowser.Server.Implementations/Collections/CollectionManager.cs

@@ -4,13 +4,13 @@ using MediaBrowser.Controller.Entities;
 using MediaBrowser.Controller.Entities.Movies;
 using MediaBrowser.Controller.Library;
 using MediaBrowser.Controller.Providers;
+using MoreLinq;
 using System;
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
-using MoreLinq;
 
 namespace MediaBrowser.Server.Implementations.Collections
 {
@@ -27,6 +27,12 @@ namespace MediaBrowser.Server.Implementations.Collections
             _iLibraryMonitor = iLibraryMonitor;
         }
 
+        public Folder GetCollectionsFolder(string userId)
+        {
+            return _libraryManager.RootFolder.Children.Concat(_libraryManager.RootFolder.GetHiddenChildren()).OfType<ManualCollectionsFolder>()
+                .FirstOrDefault();
+        }
+
         public async Task<BoxSet> CreateCollection(CollectionCreationOptions options)
         {
             var name = options.Name;
@@ -104,8 +110,7 @@ namespace MediaBrowser.Server.Implementations.Collections
                 }
             }
 
-            return _libraryManager.RootFolder.Children.OfType<ManualCollectionsFolder>().FirstOrDefault() ??
-                _libraryManager.RootFolder.GetHiddenChildren().OfType<ManualCollectionsFolder>().FirstOrDefault();
+            return GetCollectionsFolder(string.Empty);
         }
 
         public async Task AddToCollection(Guid collectionId, IEnumerable<Guid> ids)

+ 5 - 0
MediaBrowser.Server.Implementations/Collections/ManualCollectionsFolder.cs

@@ -28,6 +28,11 @@ namespace MediaBrowser.Server.Implementations.Collections
             }
         }
 
+        public override bool IsHiddenFromUser(User user)
+        {
+            return true;
+        }
+
         public override string CollectionType
         {
             get { return Model.Entities.CollectionType.BoxSets; }

+ 9 - 8
MediaBrowser.Server.Implementations/Library/UserViewManager.cs

@@ -62,28 +62,29 @@ namespace MediaBrowser.Server.Implementations.Library
 
             if (recursiveChildren.OfType<Series>().Any())
             {
-                list.Add(await GetUserView(CollectionType.TvShows, user, cancellationToken).ConfigureAwait(false));
+                list.Add(await GetUserView(CollectionType.TvShows, user, string.Empty, cancellationToken).ConfigureAwait(false));
             }
 
             if (recursiveChildren.OfType<MusicAlbum>().Any() ||
                 recursiveChildren.OfType<MusicVideo>().Any())
             {
-                list.Add(await GetUserView(CollectionType.Music, user, cancellationToken).ConfigureAwait(false));
+                list.Add(await GetUserView(CollectionType.Music, user, string.Empty, cancellationToken).ConfigureAwait(false));
             }
 
             if (recursiveChildren.OfType<Movie>().Any())
             {
-                list.Add(await GetUserView(CollectionType.Movies, user, cancellationToken).ConfigureAwait(false));
+                list.Add(await GetUserView(CollectionType.Movies, user, string.Empty, cancellationToken).ConfigureAwait(false));
             }
 
             if (recursiveChildren.OfType<Game>().Any())
             {
-                list.Add(await GetUserView(CollectionType.Games, user, cancellationToken).ConfigureAwait(false));
+                list.Add(await GetUserView(CollectionType.Games, user, string.Empty, cancellationToken).ConfigureAwait(false));
             }
 
-            if (recursiveChildren.OfType<BoxSet>().Any())
+            if (user.Configuration.DisplayCollectionsView ||
+                recursiveChildren.OfType<BoxSet>().Any())
             {
-                list.Add(await GetUserView(CollectionType.BoxSets, user, cancellationToken).ConfigureAwait(false));
+                list.Add(await GetUserView(CollectionType.BoxSets, user, "zzz_" + CollectionType.BoxSets, cancellationToken).ConfigureAwait(false));
             }
 
             if (query.IncludeExternalContent)
@@ -116,11 +117,11 @@ namespace MediaBrowser.Server.Implementations.Library
             return list.OrderBy(i => i.SortName);
         }
 
-        private Task<UserView> GetUserView(string type, User user, CancellationToken cancellationToken)
+        private Task<UserView> GetUserView(string type, User user, string sortName, CancellationToken cancellationToken)
         {
             var name = _localizationManager.GetLocalizedString("ViewType" + type);
 
-            return _libraryManager.GetNamedView(name, type, string.Empty, cancellationToken);
+            return _libraryManager.GetNamedView(name, type, sortName, cancellationToken);
         }
     }
 }