2020-05-29 09:28:19 +00:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-01-13 19:54:44 +00:00
|
|
|
using System.Collections.Generic;
|
2019-01-13 19:23:38 +00:00
|
|
|
using Emby.Server.Implementations.Images;
|
|
|
|
using MediaBrowser.Common.Configuration;
|
2017-10-21 16:39:52 +00:00
|
|
|
using MediaBrowser.Controller.Drawing;
|
2019-01-13 19:23:38 +00:00
|
|
|
using MediaBrowser.Controller.Dto;
|
2017-10-21 16:39:52 +00:00
|
|
|
using MediaBrowser.Controller.Entities;
|
2019-01-13 19:23:38 +00:00
|
|
|
using MediaBrowser.Controller.Entities.Audio;
|
|
|
|
using MediaBrowser.Controller.Library;
|
2017-10-21 16:39:52 +00:00
|
|
|
using MediaBrowser.Controller.Providers;
|
|
|
|
using MediaBrowser.Model.Entities;
|
2019-01-13 19:23:38 +00:00
|
|
|
using MediaBrowser.Model.IO;
|
2017-10-21 16:39:52 +00:00
|
|
|
using MediaBrowser.Model.Querying;
|
|
|
|
|
2019-02-09 09:10:33 +00:00
|
|
|
namespace Emby.Server.Implementations.UserViews
|
2017-10-21 16:39:52 +00:00
|
|
|
{
|
|
|
|
public abstract class BaseFolderImageProvider<T> : BaseDynamicImageProvider<T>
|
2018-09-12 17:26:21 +00:00
|
|
|
where T : Folder, new()
|
2017-10-21 16:39:52 +00:00
|
|
|
{
|
|
|
|
protected ILibraryManager _libraryManager;
|
|
|
|
|
|
|
|
public BaseFolderImageProvider(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-10-21 16:39:52 +00:00
|
|
|
{
|
|
|
|
return _libraryManager.GetItemList(new InternalItemsQuery
|
|
|
|
{
|
2018-09-12 17:26:21 +00:00
|
|
|
Parent = item,
|
2017-10-21 16:39:52 +00:00
|
|
|
DtoOptions = new DtoOptions(true),
|
2018-09-12 17:26:21 +00:00
|
|
|
ImageTypes = new ImageType[] { ImageType.Primary },
|
2019-01-07 23:27:46 +00:00
|
|
|
OrderBy = new System.ValueTuple<string, SortOrder>[]
|
2018-09-12 17:26:21 +00:00
|
|
|
{
|
|
|
|
new System.ValueTuple<string, SortOrder>(ItemSortBy.IsFolder, SortOrder.Ascending),
|
|
|
|
new System.ValueTuple<string, SortOrder>(ItemSortBy.SortName, SortOrder.Ascending)
|
|
|
|
},
|
|
|
|
Limit = 1
|
2017-10-21 16:39:52 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-03-07 14:54:30 +00:00
|
|
|
protected override string CreateImage(BaseItem item, IReadOnlyCollection<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
|
2017-10-21 16:39:52 +00:00
|
|
|
{
|
|
|
|
return CreateSingleImage(itemsWithImages, outputPathWithoutExtension, ImageType.Primary);
|
|
|
|
}
|
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
protected override bool Supports(BaseItem item)
|
2017-10-21 16:39:52 +00:00
|
|
|
{
|
2018-09-12 17:26:21 +00:00
|
|
|
return item is T;
|
2017-10-21 16:39:52 +00:00
|
|
|
}
|
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
protected override bool HasChangedByDate(BaseItem item, ItemImageInfo image)
|
2017-10-21 16:39:52 +00:00
|
|
|
{
|
|
|
|
if (item is MusicAlbum)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return base.HasChangedByDate(item, image);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class FolderImageProvider : BaseFolderImageProvider<Folder>
|
|
|
|
{
|
|
|
|
public FolderImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor, ILibraryManager libraryManager)
|
|
|
|
: base(fileSystem, providerManager, applicationPaths, imageProcessor, libraryManager)
|
|
|
|
{
|
|
|
|
}
|
2018-09-12 17:26:21 +00:00
|
|
|
|
|
|
|
protected override bool Supports(BaseItem item)
|
|
|
|
{
|
|
|
|
if (item is PhotoAlbum || item is MusicAlbum)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-05-29 09:28:19 +00:00
|
|
|
if (item is Folder folder)
|
2018-09-12 17:26:21 +00:00
|
|
|
{
|
|
|
|
if (folder.IsTopParent)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2020-05-29 09:28:19 +00:00
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
return true;
|
|
|
|
//return item.SourceType == SourceType.Library;
|
|
|
|
}
|
2017-10-21 16:39:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public class MusicAlbumImageProvider : BaseFolderImageProvider<MusicAlbum>
|
|
|
|
{
|
|
|
|
public MusicAlbumImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor, ILibraryManager libraryManager)
|
|
|
|
: base(fileSystem, providerManager, applicationPaths, imageProcessor, libraryManager)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class PhotoAlbumImageProvider : BaseFolderImageProvider<PhotoAlbum>
|
|
|
|
{
|
|
|
|
public PhotoAlbumImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor, ILibraryManager libraryManager)
|
|
|
|
: base(fileSystem, providerManager, applicationPaths, imageProcessor, libraryManager)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|