From aa66444264fe0f76349316496fd5a6e8d3431b7d Mon Sep 17 00:00:00 2001 From: dkanada Date: Sat, 14 Dec 2019 15:01:43 +0900 Subject: [PATCH] add image provider for artists --- .../Images/BaseDynamicImageProvider.cs | 2 +- .../Playlists/PlaylistImageProvider.cs | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs b/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs index 9bbd71b964..23cef216c8 100644 --- a/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs +++ b/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs @@ -215,7 +215,7 @@ namespace Emby.Server.Implementations.Images if (imageType == ImageType.Primary) { - if (item is UserView || item is Playlist || item is MusicGenre || item is Genre || item is PhotoAlbum) + if (item is UserView || item is Playlist || item is MusicGenre || item is Genre || item is PhotoAlbum || item is MusicArtist) { return CreateSquareCollage(item, itemsWithImages, outputPath); } diff --git a/Emby.Server.Implementations/Playlists/PlaylistImageProvider.cs b/Emby.Server.Implementations/Playlists/PlaylistImageProvider.cs index f8a2d97417..b8944e06aa 100644 --- a/Emby.Server.Implementations/Playlists/PlaylistImageProvider.cs +++ b/Emby.Server.Implementations/Playlists/PlaylistImageProvider.cs @@ -67,6 +67,30 @@ namespace Emby.Server.Implementations.Playlists } } + public class MusicArtistImageProvider : BaseDynamicImageProvider + { + private readonly ILibraryManager _libraryManager; + + public MusicArtistImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor, ILibraryManager libraryManager) : base(fileSystem, providerManager, applicationPaths, imageProcessor) + { + _libraryManager = libraryManager; + } + + protected override IReadOnlyList GetItemsWithImages(BaseItem item) + { + return _libraryManager.GetItemList(new InternalItemsQuery + { + ArtistIds = new[] { item.Id }, + IncludeItemTypes = new[] { typeof(MusicAlbum).Name }, + OrderBy = new[] { (ItemSortBy.Random, SortOrder.Ascending) }, + Limit = 4, + Recursive = true, + ImageTypes = new[] { ImageType.Primary }, + DtoOptions = new DtoOptions(false) + }); + } + } + public class MusicGenreImageProvider : BaseDynamicImageProvider { private readonly ILibraryManager _libraryManager;