jellyfin/Emby.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs

57 lines
1.7 KiB
C#
Raw Normal View History

2015-04-08 07:38:02 -07:00
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Entities;
2014-08-28 21:06:30 -07:00
using MediaBrowser.Controller.Library;
2014-12-19 23:06:27 -07:00
using MediaBrowser.Controller.Resolvers;
2014-08-28 21:06:30 -07:00
using MediaBrowser.Model.Entities;
using System;
using System.IO;
using System.Linq;
namespace Emby.Server.Implementations.Library.Resolvers
2014-08-28 21:06:30 -07:00
{
public class PhotoAlbumResolver : FolderResolver<PhotoAlbum>
{
2015-04-08 07:38:02 -07:00
private readonly IImageProcessor _imageProcessor;
public PhotoAlbumResolver(IImageProcessor imageProcessor)
{
_imageProcessor = imageProcessor;
}
2014-08-28 21:06:30 -07:00
/// <summary>
/// Resolves the specified args.
/// </summary>
/// <param name="args">The args.</param>
/// <returns>Trailer.</returns>
protected override PhotoAlbum Resolve(ItemResolveArgs args)
{
// Must be an image file within a photo collection
2014-12-19 23:06:27 -07:00
if (args.IsDirectory && string.Equals(args.GetCollectionType(), CollectionType.Photos, StringComparison.OrdinalIgnoreCase))
2014-08-28 21:06:30 -07:00
{
if (HasPhotos(args))
{
return new PhotoAlbum
{
Path = args.Path
};
}
}
return null;
}
2015-04-08 07:38:02 -07:00
private bool HasPhotos(ItemResolveArgs args)
2014-08-28 21:06:30 -07:00
{
2016-10-25 12:02:04 -07:00
return args.FileSystemChildren.Any(i => (!i.IsDirectory) && PhotoResolver.IsImageFile(i.FullName, _imageProcessor));
2014-08-28 21:06:30 -07:00
}
2014-12-19 23:06:27 -07:00
public override ResolverPriority Priority
{
get
{
// Behind special folder resolver
return ResolverPriority.Second;
}
}
2014-08-28 21:06:30 -07:00
}
}