mirror of
				https://github.com/jellyfin/jellyfin.git
				synced 2025-11-03 19:17:24 -05:00 
			
		
		
		
	add library folder option to home page
This commit is contained in:
		
							parent
							
								
									0b60e7ca67
								
							
						
					
					
						commit
						f72b1f531a
					
				@ -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)
 | 
			
		||||
 | 
			
		||||
@ -11,5 +11,10 @@ namespace MediaBrowser.Controller.Entities
 | 
			
		||||
        {
 | 
			
		||||
            DisplayMediaType = "CollectionFolder";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public string CollectionType
 | 
			
		||||
        {
 | 
			
		||||
            get { return Model.Entities.CollectionType.BoxSets; }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -6,5 +6,6 @@ namespace MediaBrowser.Controller.Entities
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public interface ICollectionFolder
 | 
			
		||||
    {
 | 
			
		||||
        string CollectionType { get; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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
									
								
								MediaBrowser.Providers/FolderImages/DefaultImageProvider.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										127
									
								
								MediaBrowser.Providers/FolderImages/DefaultImageProvider.cs
									
									
									
									
									
										Normal file
									
								
							@ -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
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -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" />
 | 
			
		||||
 | 
			
		||||
@ -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",
 | 
			
		||||
 | 
			
		||||
@ -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"
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user