source music genre images from library content

This commit is contained in:
Luke Pulverenti 2016-07-23 01:44:46 -04:00
parent e853b35fd8
commit 2aeee846f4
2 changed files with 36 additions and 1 deletions

View File

@ -13,6 +13,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Model.Configuration;
namespace MediaBrowser.Server.Implementations.Photos
@ -247,7 +248,7 @@ namespace MediaBrowser.Server.Implementations.Photos
{
return await CreateSquareCollage(item, itemsWithImages, outputPath).ConfigureAwait(false);
}
if (item is Playlist)
if (item is Playlist || item is MusicGenre)
{
return await CreateSquareCollage(item, itemsWithImages, outputPath).ConfigureAwait(false);
}

View File

@ -12,6 +12,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Querying;
namespace MediaBrowser.Server.Implementations.Playlists
{
@ -65,4 +67,36 @@ namespace MediaBrowser.Server.Implementations.Playlists
return Task.FromResult(GetFinalItems(items));
}
}
public class MusicGenreImageProvider : BaseDynamicImageProvider<MusicGenre>
{
private readonly ILibraryManager _libraryManager;
public MusicGenreImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor, ILibraryManager libraryManager) : base(fileSystem, providerManager, applicationPaths, imageProcessor)
{
_libraryManager = libraryManager;
}
protected override Task<List<BaseItem>> GetItemsWithImages(IHasImages item)
{
var items = _libraryManager.GetItemList(new InternalItemsQuery
{
Genres = new[] { item.Name },
IncludeItemTypes = new[] { typeof(MusicAlbum).Name, typeof(MusicVideo).Name, typeof(Audio).Name },
SortBy = new[] { ItemSortBy.Random },
Limit = 4,
Recursive = true,
ImageTypes = new[] { ImageType.Primary }
}).ToList();
return Task.FromResult(GetFinalItems(items));
}
//protected override Task<string> CreateImage(IHasImages item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
//{
// return CreateSingleImage(itemsWithImages, outputPathWithoutExtension, ImageType.Primary);
//}
}
}