2015-07-27 05:03:34 +00:00
|
|
|
|
using MediaBrowser.Common.Configuration;
|
|
|
|
|
using MediaBrowser.Controller.Drawing;
|
|
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
|
using MediaBrowser.Controller.Entities.Audio;
|
|
|
|
|
using MediaBrowser.Controller.Entities.TV;
|
|
|
|
|
using MediaBrowser.Controller.Providers;
|
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2015-10-26 05:29:32 +00:00
|
|
|
|
using System.IO;
|
2015-07-27 05:03:34 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
2016-11-03 07:14:14 +00:00
|
|
|
|
using Emby.Server.Implementations.Images;
|
2016-10-25 19:02:04 +00:00
|
|
|
|
using MediaBrowser.Model.IO;
|
2016-09-05 20:07:36 +00:00
|
|
|
|
using MediaBrowser.Controller.Collections;
|
2017-05-21 07:25:49 +00:00
|
|
|
|
using MediaBrowser.Controller.Dto;
|
2016-09-05 20:07:36 +00:00
|
|
|
|
using MediaBrowser.Controller.Entities.Movies;
|
2016-10-25 19:02:04 +00:00
|
|
|
|
using MediaBrowser.Controller.IO;
|
2016-09-05 20:07:36 +00:00
|
|
|
|
using MediaBrowser.Controller.Library;
|
2016-10-22 02:08:34 +00:00
|
|
|
|
using MediaBrowser.Model.Extensions;
|
2016-09-05 20:07:36 +00:00
|
|
|
|
using MediaBrowser.Model.Querying;
|
2015-07-27 05:03:34 +00:00
|
|
|
|
|
2016-11-03 07:14:14 +00:00
|
|
|
|
namespace Emby.Server.Implementations.UserViews
|
2015-07-27 05:03:34 +00:00
|
|
|
|
{
|
|
|
|
|
public class CollectionFolderImageProvider : BaseDynamicImageProvider<CollectionFolder>
|
|
|
|
|
{
|
|
|
|
|
public CollectionFolderImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor) : base(fileSystem, providerManager, applicationPaths, imageProcessor)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
|
protected override List<BaseItem> GetItemsWithImages(BaseItem item)
|
2015-07-27 05:03:34 +00:00
|
|
|
|
{
|
|
|
|
|
var view = (CollectionFolder)item;
|
2018-09-12 17:26:21 +00:00
|
|
|
|
var viewType = view.CollectionType;
|
2015-07-27 05:03:34 +00:00
|
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
|
string[] includeItemTypes;
|
2015-07-27 05:03:34 +00:00
|
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
|
if (string.Equals(viewType, CollectionType.Movies))
|
2015-07-27 05:03:34 +00:00
|
|
|
|
{
|
2018-09-12 17:26:21 +00:00
|
|
|
|
includeItemTypes = new string[] { "Movie" };
|
|
|
|
|
}
|
|
|
|
|
else if (string.Equals(viewType, CollectionType.TvShows))
|
2015-07-27 05:03:34 +00:00
|
|
|
|
{
|
2018-09-12 17:26:21 +00:00
|
|
|
|
includeItemTypes = new string[] { "Series" };
|
|
|
|
|
}
|
|
|
|
|
else if (string.Equals(viewType, CollectionType.Music))
|
2015-07-27 05:03:34 +00:00
|
|
|
|
{
|
2018-09-12 17:26:21 +00:00
|
|
|
|
includeItemTypes = new string[] { "MusicAlbum" };
|
|
|
|
|
}
|
|
|
|
|
else if (string.Equals(viewType, CollectionType.Books))
|
|
|
|
|
{
|
|
|
|
|
includeItemTypes = new string[] { "Book", "AudioBook" };
|
|
|
|
|
}
|
|
|
|
|
else if (string.Equals(viewType, CollectionType.Games))
|
|
|
|
|
{
|
|
|
|
|
includeItemTypes = new string[] { "Game" };
|
|
|
|
|
}
|
|
|
|
|
else if (string.Equals(viewType, CollectionType.BoxSets))
|
|
|
|
|
{
|
|
|
|
|
includeItemTypes = new string[] { "BoxSet" };
|
|
|
|
|
}
|
|
|
|
|
else if (string.Equals(viewType, CollectionType.HomeVideos) || string.Equals(viewType, CollectionType.Photos))
|
|
|
|
|
{
|
|
|
|
|
includeItemTypes = new string[] { "Video", "Photo" };
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
includeItemTypes = new string[] { "Video", "Audio", "Photo", "Movie", "Series" };
|
2015-07-27 05:03:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
|
var recursive = !new[] { CollectionType.Playlists }.Contains(view.CollectionType ?? string.Empty, StringComparer.OrdinalIgnoreCase);
|
2016-09-05 20:07:36 +00:00
|
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
|
return view.GetItemList(new InternalItemsQuery
|
2016-09-05 20:07:36 +00:00
|
|
|
|
{
|
2018-09-12 17:26:21 +00:00
|
|
|
|
CollapseBoxSetItems = false,
|
2016-09-05 20:07:36 +00:00
|
|
|
|
Recursive = recursive,
|
2018-09-12 17:26:21 +00:00
|
|
|
|
DtoOptions = new DtoOptions(false),
|
|
|
|
|
ImageTypes = new ImageType[] { ImageType.Primary },
|
|
|
|
|
Limit = 8,
|
|
|
|
|
OrderBy = new ValueTuple<string, SortOrder>[]
|
|
|
|
|
{
|
|
|
|
|
new ValueTuple<string, SortOrder>(ItemSortBy.Random, SortOrder.Ascending)
|
|
|
|
|
},
|
|
|
|
|
IncludeItemTypes = includeItemTypes
|
2016-09-05 20:07:36 +00:00
|
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
|
}).ToList();
|
2016-09-05 20:07:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
|
protected override bool Supports(BaseItem item)
|
2016-09-05 20:07:36 +00:00
|
|
|
|
{
|
2018-09-12 17:26:21 +00:00
|
|
|
|
return item is CollectionFolder;
|
2016-09-05 20:07:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
|
protected override string CreateImage(BaseItem item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
|
2016-09-05 20:07:36 +00:00
|
|
|
|
{
|
|
|
|
|
var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ".png");
|
|
|
|
|
|
|
|
|
|
if (imageType == ImageType.Primary)
|
|
|
|
|
{
|
|
|
|
|
if (itemsWithImages.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-19 17:09:37 +00:00
|
|
|
|
return CreateThumbCollage(item, itemsWithImages, outputPath, 960, 540);
|
2016-09-05 20:07:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-19 17:09:37 +00:00
|
|
|
|
return base.CreateImage(item, itemsWithImages, outputPath, imageType, imageIndex);
|
2016-09-05 20:07:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-27 05:03:34 +00:00
|
|
|
|
}
|