jellyfin-server/MediaBrowser.Server.Implementations/Photos/PhotoAlbumImageProvider.cs

46 lines
1.6 KiB
C#
Raw Normal View History

2015-05-13 14:43:34 +00:00
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Entities;
2014-10-29 22:01:02 +00:00
using MediaBrowser.Controller.Providers;
2014-08-12 02:59:51 +00:00
using System.Collections.Generic;
2015-10-26 05:29:32 +00:00
using System.IO;
2014-08-12 02:59:51 +00:00
using System.Linq;
using System.Threading.Tasks;
2015-10-04 04:23:11 +00:00
using CommonIO;
2014-08-12 02:59:51 +00:00
2014-10-20 03:04:45 +00:00
namespace MediaBrowser.Server.Implementations.Photos
2014-08-12 02:59:51 +00:00
{
2015-05-13 14:43:34 +00:00
public class PhotoAlbumImageProvider : BaseDynamicImageProvider<PhotoAlbum>
2015-05-10 21:56:13 +00:00
{
2015-05-13 14:43:34 +00:00
public PhotoAlbumImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor)
: base(fileSystem, providerManager, applicationPaths, imageProcessor)
2015-05-10 21:56:13 +00:00
{
}
2014-10-20 03:04:45 +00:00
2015-05-13 14:43:34 +00:00
protected override Task<List<BaseItem>> GetItemsWithImages(IHasImages item)
2015-05-10 21:56:13 +00:00
{
2015-05-13 14:43:34 +00:00
var photoAlbum = (PhotoAlbum)item;
2015-10-26 05:29:32 +00:00
var items = GetFinalItems(photoAlbum.Children.ToList(), 1);
2014-10-20 03:04:45 +00:00
2015-05-13 14:43:34 +00:00
return Task.FromResult(items);
2015-05-10 21:56:13 +00:00
}
2015-10-26 05:29:32 +00:00
protected override async Task<string> CreateImage(IHasImages item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, Model.Entities.ImageType imageType, int imageIndex)
{
var photoFile = itemsWithImages.Where(i => Path.HasExtension(i.Path)).Select(i => i.Path).FirstOrDefault();
if (string.IsNullOrWhiteSpace(photoFile))
{
return null;
}
var ext = Path.GetExtension(photoFile);
var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ext);
File.Copy(photoFile, outputPath);
return outputPath;
}
2015-05-10 21:56:13 +00:00
}
2014-08-12 02:59:51 +00:00
}