2017-10-21 12:39:52 -04:00
|
|
|
|
using MediaBrowser.Common.Configuration;
|
|
|
|
|
using MediaBrowser.Controller.Drawing;
|
|
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
|
using MediaBrowser.Controller.Providers;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Emby.Server.Implementations.Images;
|
|
|
|
|
using MediaBrowser.Model.IO;
|
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
|
using MediaBrowser.Controller.Entities.Audio;
|
|
|
|
|
using MediaBrowser.Model.Dto;
|
|
|
|
|
using MediaBrowser.Model.Querying;
|
|
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
|
|
using MediaBrowser.Controller.Dto;
|
|
|
|
|
|
|
|
|
|
namespace Emby.Server.Implementations.Photos
|
|
|
|
|
{
|
|
|
|
|
public abstract class BaseFolderImageProvider<T> : BaseDynamicImageProvider<T>
|
2018-09-12 13:26:21 -04:00
|
|
|
|
where T : Folder, new()
|
2017-10-21 12:39:52 -04:00
|
|
|
|
{
|
|
|
|
|
protected ILibraryManager _libraryManager;
|
|
|
|
|
|
|
|
|
|
public BaseFolderImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor, ILibraryManager libraryManager)
|
|
|
|
|
: base(fileSystem, providerManager, applicationPaths, imageProcessor)
|
|
|
|
|
{
|
|
|
|
|
_libraryManager = libraryManager;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-12 13:26:21 -04:00
|
|
|
|
protected override List<BaseItem> GetItemsWithImages(BaseItem item)
|
2017-10-21 12:39:52 -04:00
|
|
|
|
{
|
|
|
|
|
return _libraryManager.GetItemList(new InternalItemsQuery
|
|
|
|
|
{
|
2018-09-12 13:26:21 -04:00
|
|
|
|
Parent = item,
|
2017-10-21 12:39:52 -04:00
|
|
|
|
DtoOptions = new DtoOptions(true),
|
2018-09-12 13:26:21 -04:00
|
|
|
|
ImageTypes = new ImageType[] { ImageType.Primary },
|
2019-01-07 18:27:46 -05:00
|
|
|
|
OrderBy = new System.ValueTuple<string, SortOrder>[]
|
2018-09-12 13:26:21 -04:00
|
|
|
|
{
|
|
|
|
|
new System.ValueTuple<string, SortOrder>(ItemSortBy.IsFolder, SortOrder.Ascending),
|
|
|
|
|
new System.ValueTuple<string, SortOrder>(ItemSortBy.SortName, SortOrder.Ascending)
|
|
|
|
|
},
|
|
|
|
|
Limit = 1
|
2017-10-21 12:39:52 -04:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-12 13:26:21 -04:00
|
|
|
|
protected override string CreateImage(BaseItem item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
|
2017-10-21 12:39:52 -04:00
|
|
|
|
{
|
|
|
|
|
return CreateSingleImage(itemsWithImages, outputPathWithoutExtension, ImageType.Primary);
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-12 13:26:21 -04:00
|
|
|
|
protected override bool Supports(BaseItem item)
|
2017-10-21 12:39:52 -04:00
|
|
|
|
{
|
2018-09-12 13:26:21 -04:00
|
|
|
|
return item is T;
|
2017-10-21 12:39:52 -04:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-12 13:26:21 -04:00
|
|
|
|
protected override bool HasChangedByDate(BaseItem item, ItemImageInfo image)
|
2017-10-21 12:39:52 -04: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 13:26:21 -04:00
|
|
|
|
|
|
|
|
|
protected override bool Supports(BaseItem item)
|
|
|
|
|
{
|
|
|
|
|
if (item is PhotoAlbum || item is MusicAlbum)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var folder = item as Folder;
|
|
|
|
|
if (folder != null)
|
|
|
|
|
{
|
|
|
|
|
if (folder.IsTopParent)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
//return item.SourceType == SourceType.Library;
|
|
|
|
|
}
|
2017-10-21 12:39:52 -04: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)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|