2019-01-13 19:54:44 +00:00
|
|
|
using System;
|
2019-01-13 19:22:00 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using Emby.Server.Implementations.Images;
|
2017-09-04 19:28:22 +00:00
|
|
|
using MediaBrowser.Common.Configuration;
|
2015-04-08 14:38:02 +00:00
|
|
|
using MediaBrowser.Controller.Drawing;
|
2019-01-13 19:22:00 +00:00
|
|
|
using MediaBrowser.Controller.Dto;
|
2014-08-12 02:59:51 +00:00
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
using MediaBrowser.Controller.Entities.Audio;
|
2019-01-13 19:22:00 +00:00
|
|
|
using MediaBrowser.Controller.Entities.Movies;
|
2014-08-12 02:59:51 +00:00
|
|
|
using MediaBrowser.Controller.Entities.TV;
|
2019-01-13 19:22:00 +00:00
|
|
|
using MediaBrowser.Controller.Library;
|
2014-08-12 02:59:51 +00:00
|
|
|
using MediaBrowser.Controller.Playlists;
|
|
|
|
using MediaBrowser.Controller.Providers;
|
|
|
|
using MediaBrowser.Model.Entities;
|
2019-01-13 19:22:00 +00:00
|
|
|
using MediaBrowser.Model.IO;
|
2016-07-23 05:44:46 +00:00
|
|
|
using MediaBrowser.Model.Querying;
|
2014-08-12 02:59:51 +00:00
|
|
|
|
2016-11-03 07:14:14 +00:00
|
|
|
namespace Emby.Server.Implementations.Playlists
|
2014-08-12 02:59:51 +00:00
|
|
|
{
|
2015-03-13 19:16:34 +00:00
|
|
|
public class PlaylistImageProvider : BaseDynamicImageProvider<Playlist>
|
2014-08-12 02:59:51 +00:00
|
|
|
{
|
2015-04-08 14:38:02 +00:00
|
|
|
public PlaylistImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor) : base(fileSystem, providerManager, applicationPaths, imageProcessor)
|
2014-10-20 03:04:45 +00:00
|
|
|
{
|
2014-08-12 02:59:51 +00:00
|
|
|
}
|
|
|
|
|
2019-03-07 14:54:30 +00:00
|
|
|
protected override IReadOnlyList<BaseItem> GetItemsWithImages(BaseItem item)
|
2014-08-12 02:59:51 +00:00
|
|
|
{
|
|
|
|
var playlist = (Playlist)item;
|
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
return playlist.GetManageableItems()
|
2014-08-12 02:59:51 +00:00
|
|
|
.Select(i =>
|
|
|
|
{
|
|
|
|
var subItem = i.Item2;
|
|
|
|
|
|
|
|
var episode = subItem as Episode;
|
|
|
|
|
|
|
|
if (episode != null)
|
|
|
|
{
|
|
|
|
var series = episode.Series;
|
|
|
|
if (series != null && series.HasImage(ImageType.Primary))
|
|
|
|
{
|
|
|
|
return series;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (subItem.HasImage(ImageType.Primary))
|
|
|
|
{
|
|
|
|
return subItem;
|
|
|
|
}
|
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
var parent = subItem.GetOwner() ?? subItem.GetParent();
|
2014-08-12 02:59:51 +00:00
|
|
|
|
|
|
|
if (parent != null && parent.HasImage(ImageType.Primary))
|
|
|
|
{
|
|
|
|
if (parent is MusicAlbum)
|
|
|
|
{
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
})
|
|
|
|
.Where(i => i != null)
|
2018-09-12 17:26:21 +00:00
|
|
|
.OrderBy(i => Guid.NewGuid())
|
2019-02-02 11:27:06 +00:00
|
|
|
.GroupBy(x => x.Id)
|
|
|
|
.Select(x => x.First())
|
2018-09-12 17:26:21 +00:00
|
|
|
.ToList();
|
2014-10-20 03:04:45 +00:00
|
|
|
}
|
2014-08-12 02:59:51 +00:00
|
|
|
}
|
2016-07-23 05:44:46 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-03-07 14:54:30 +00:00
|
|
|
protected override IReadOnlyList<BaseItem> GetItemsWithImages(BaseItem item)
|
2016-07-23 05:44:46 +00:00
|
|
|
{
|
2018-09-12 17:26:21 +00:00
|
|
|
return _libraryManager.GetItemList(new InternalItemsQuery
|
2016-07-23 05:44:46 +00:00
|
|
|
{
|
|
|
|
Genres = new[] { item.Name },
|
|
|
|
IncludeItemTypes = new[] { typeof(MusicAlbum).Name, typeof(MusicVideo).Name, typeof(Audio).Name },
|
2018-09-12 17:26:21 +00:00
|
|
|
OrderBy = new[] { new ValueTuple<string, SortOrder>(ItemSortBy.Random, SortOrder.Ascending) },
|
2016-07-23 05:44:46 +00:00
|
|
|
Limit = 4,
|
|
|
|
Recursive = true,
|
2017-05-21 07:25:49 +00:00
|
|
|
ImageTypes = new[] { ImageType.Primary },
|
|
|
|
DtoOptions = new DtoOptions(false)
|
2017-08-09 19:56:38 +00:00
|
|
|
});
|
2016-07-23 05:44:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-10 18:32:38 +00:00
|
|
|
public class GenreImageProvider : BaseDynamicImageProvider<Genre>
|
|
|
|
{
|
|
|
|
private readonly ILibraryManager _libraryManager;
|
|
|
|
|
|
|
|
public GenreImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor, ILibraryManager libraryManager) : base(fileSystem, providerManager, applicationPaths, imageProcessor)
|
|
|
|
{
|
|
|
|
_libraryManager = libraryManager;
|
|
|
|
}
|
|
|
|
|
2019-03-07 14:54:30 +00:00
|
|
|
protected override IReadOnlyList<BaseItem> GetItemsWithImages(BaseItem item)
|
2017-03-10 18:32:38 +00:00
|
|
|
{
|
2018-09-12 17:26:21 +00:00
|
|
|
return _libraryManager.GetItemList(new InternalItemsQuery
|
2017-03-10 18:32:38 +00:00
|
|
|
{
|
|
|
|
Genres = new[] { item.Name },
|
|
|
|
IncludeItemTypes = new[] { typeof(Series).Name, typeof(Movie).Name },
|
2018-09-12 17:26:21 +00:00
|
|
|
OrderBy = new[] { new ValueTuple<string, SortOrder>(ItemSortBy.Random, SortOrder.Ascending) },
|
2017-03-10 18:32:38 +00:00
|
|
|
Limit = 4,
|
|
|
|
Recursive = true,
|
2017-05-21 07:25:49 +00:00
|
|
|
ImageTypes = new[] { ImageType.Primary },
|
|
|
|
DtoOptions = new DtoOptions(false)
|
2017-08-09 19:56:38 +00:00
|
|
|
});
|
2017-03-10 18:32:38 +00:00
|
|
|
}
|
|
|
|
}
|
2014-08-12 02:59:51 +00:00
|
|
|
}
|