瀏覽代碼

add library folder option to home page

Luke Pulverenti 11 年之前
父節點
當前提交
f72b1f531a

+ 7 - 0
MediaBrowser.Api/BaseApiService.cs

@@ -160,6 +160,13 @@ namespace MediaBrowser.Api
             {
                 var folder = (Folder) libraryManager.GetItemById(new Guid(parentId));
 
+                if (userId.HasValue)
+                {
+                    var user = userManager.GetUserById(userId.Value);
+
+                    return folder.GetRecursiveChildren(user).ToList();
+                }
+
                 return folder.GetRecursiveChildren();
             }
             if (userId.HasValue)

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

@@ -11,5 +11,10 @@ namespace MediaBrowser.Controller.Entities
         {
             DisplayMediaType = "CollectionFolder";
         }
+
+        public string CollectionType
+        {
+            get { return Model.Entities.CollectionType.BoxSets; }
+        }
     }
 }

+ 1 - 0
MediaBrowser.Controller/Entities/ICollectionFolder.cs

@@ -6,5 +6,6 @@ namespace MediaBrowser.Controller.Entities
     /// </summary>
     public interface ICollectionFolder
     {
+        string CollectionType { get; }
     }
 }

+ 2 - 2
MediaBrowser.Dlna/Didl/DidlBuilder.cs

@@ -423,7 +423,7 @@ namespace MediaBrowser.Dlna.Didl
                     else if (item is Series || item is Season || item is BoxSet)
                     {
                         classType = "object.container.album.videoAlbum";
-                    }                  
+                    }
                 }
 
                 objectClass.InnerText = classType ?? "object.container.storageFolder";
@@ -441,7 +441,7 @@ namespace MediaBrowser.Dlna.Didl
                 if (!_profile.RequiresPlainVideoItems && item is Movie)
                 {
                     objectClass.InnerText = "object.item.videoItem.movie";
-                }                
+                }
                 else
                 {
                     objectClass.InnerText = "object.item.videoItem";

+ 4 - 2
MediaBrowser.Dlna/PlayTo/PlayToController.cs

@@ -463,7 +463,8 @@ namespace MediaBrowser.Dlna.PlayTo
                         ItemId = item.Id.ToString("N"),
                         MediaSources = mediaSources,
                         Profile = profile,
-                        DeviceId = deviceId
+                        DeviceId = deviceId,
+                        MaxBitrate = profile.MaxBitrate
                     }),
 
                     Profile = profile
@@ -481,7 +482,8 @@ namespace MediaBrowser.Dlna.PlayTo
                         ItemId = item.Id.ToString("N"),
                         MediaSources = mediaSources,
                         Profile = profile,
-                        DeviceId = deviceId
+                        DeviceId = deviceId,
+                        MaxBitrate = profile.MaxBitrate
                     }),
 
                     Profile = profile

+ 2 - 0
MediaBrowser.Model/Entities/CollectionType.cs

@@ -22,5 +22,7 @@ namespace MediaBrowser.Model.Entities
         public const string Books = "books";
         public const string Photos = "photos";
         public const string Games = "games";
+        public const string Channels = "channels";
+        public const string LiveTv = "livetv";
     }
 }

+ 127 - 0
MediaBrowser.Providers/FolderImages/DefaultImageProvider.cs

@@ -0,0 +1,127 @@
+using MediaBrowser.Common.Net;
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Providers;
+using MediaBrowser.Model.Entities;
+using MediaBrowser.Model.Providers;
+using MediaBrowser.Providers.Genres;
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace MediaBrowser.Providers.FolderImages
+{
+    public class DefaultImageProvider : IRemoteImageProvider
+    {
+        private readonly IHttpClient _httpClient;
+
+        public DefaultImageProvider(IHttpClient httpClient)
+        {
+            _httpClient = httpClient;
+        }
+
+        public IEnumerable<ImageType> GetSupportedImages(IHasImages item)
+        {
+            return new List<ImageType>
+            {
+                ImageType.Primary,
+                ImageType.Thumb
+            };
+        }
+
+        public Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken)
+        {
+            var view = item as UserView;
+
+            if (view != null)
+            {
+                return GetImages(view.ViewType, cancellationToken);
+            }
+
+            var folder = (ICollectionFolder)item;
+            return GetImages(folder.CollectionType, cancellationToken);
+        }
+
+        private Task<IEnumerable<RemoteImageInfo>> GetImages(string viewType, CancellationToken cancellationToken)
+        {
+            var url = GetImageUrl(viewType);
+
+            return Task.FromResult<IEnumerable<RemoteImageInfo>>(new List<RemoteImageInfo>
+            {
+                 new RemoteImageInfo
+                 {
+                      ProviderName = Name,
+                      Url = url,
+                      Type = ImageType.Primary
+                 },
+
+                 new RemoteImageInfo
+                 {
+                      ProviderName = Name,
+                      Url = url,
+                      Type = ImageType.Thumb
+                 }
+            });
+        }
+
+        private string GetImageUrl(string viewType)
+        {
+            const string urlPrefix = "https://raw.githubusercontent.com/MediaBrowser/MediaBrowser.Resources/master/images/folders/";
+
+            if (string.Equals(viewType, CollectionType.Books, StringComparison.OrdinalIgnoreCase))
+            {
+                return urlPrefix + "books.jpg";
+            }
+            if (string.Equals(viewType, CollectionType.Games, StringComparison.OrdinalIgnoreCase))
+            {
+                return urlPrefix + "games.jpg";
+            }
+            if (string.Equals(viewType, CollectionType.Music, StringComparison.OrdinalIgnoreCase))
+            {
+                return urlPrefix + "music.jpg";
+            }
+            if (string.Equals(viewType, CollectionType.Photos, StringComparison.OrdinalIgnoreCase))
+            {
+                return urlPrefix + "photos.jpg";
+            }
+            if (string.Equals(viewType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
+            {
+                return urlPrefix + "tv.jpg";
+            }
+            if (string.Equals(viewType, CollectionType.Channels, StringComparison.OrdinalIgnoreCase))
+            {
+                return urlPrefix + "channels.jpg";
+            }
+            if (string.Equals(viewType, CollectionType.LiveTv, StringComparison.OrdinalIgnoreCase))
+            {
+                return urlPrefix + "livetv.jpg";
+            }
+            if (string.Equals(viewType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase))
+            {
+                return urlPrefix + "movies.jpg";
+            }
+
+            return urlPrefix + "generic.jpg";
+        }
+
+        public string Name
+        {
+            get { return "Default Image Provider"; }
+        }
+
+        public bool Supports(IHasImages item)
+        {
+            return item is UserView || item is CollectionFolder;
+        }
+
+        public Task<HttpResponseInfo> GetImageResponse(string url, CancellationToken cancellationToken)
+        {
+            return _httpClient.GetResponse(new HttpRequestOptions
+            {
+                CancellationToken = cancellationToken,
+                Url = url,
+                ResourcePool = GenreImageProvider.ImageDownloadResourcePool
+            });
+        }
+    }
+}

+ 1 - 0
MediaBrowser.Providers/MediaBrowser.Providers.csproj

@@ -80,6 +80,7 @@
     <Compile Include="BoxSets\MovieDbBoxSetProvider.cs" />
     <Compile Include="Channels\ChannelMetadataService.cs" />
     <Compile Include="Chapters\ChapterManager.cs" />
+    <Compile Include="FolderImages\DefaultImageProvider.cs" />
     <Compile Include="Folders\CollectionFolderImageProvider.cs" />
     <Compile Include="Folders\FolderMetadataService.cs" />
     <Compile Include="Folders\ImagesByNameImageProvider.cs" />

+ 1 - 0
MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json

@@ -122,6 +122,7 @@
 	"MessageConfirmItemGrouping": "Media Browser clients will automatically choose the optimal version to play based on device and network performance. Are you sure you wish to continue?",
 	"HeaderResume": "Resume",
 	"HeaderMyLibrary": "My Library",
+	"HeaderLibraryFolders": "Folder View"
 	"HeaderLatestMedia": "Latest Media",
 	"ButtonMore": "More...",
 	"HeaderFavoriteMovies": "Favorite Movies",

+ 5 - 4
MediaBrowser.Server.Implementations/Localization/Server/server.json

@@ -785,9 +785,9 @@
 	"LabelHomePageSection1": "Home page section one:",
 	"LabelHomePageSection2": "Home page section two:",
 	"LabelHomePageSection3": "Home page section three:",
-	"OptionLibraryButtons": "Library buttons",
-	"OptionLibraryTiles": "Library tiles (large)",
-	"OptionSmallLibraryTiles": "Library tiles (small)",
+	"OptionMyLibraryButtons": "My library (buttons)",
+	"OptionMyLibrary": "My library",
+	"OptionMyLibrarySmall": "My library (small)",
 	"OptionResumablemedia": "Resume",
 	"OptionLatestMedia": "Latest media",
 	"OptionNone": "None",
@@ -828,5 +828,6 @@
 	"HeaderLibraryViews": "Library Views",
 	"LabelSelectFolderGroups": "Automatically group content from the following folders into views such as Movies, Music and TV:",
 	"LabelSelectFolderGroupsHelp": "Folders that are unchecked will be displayed by themselves in their own view.",
-	"OptionDisplayAdultContent": "Display adult content"
+	"OptionDisplayAdultContent": "Display adult content",
+	"OptionLibraryFolders": "Folder view"
 }