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

57 lines
1.7 KiB
C#
Raw Normal View History

2015-04-08 14:38:02 +00:00
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Entities;
2014-08-29 04:06:30 +00:00
using MediaBrowser.Controller.Library;
2014-12-20 06:06:27 +00:00
using MediaBrowser.Controller.Resolvers;
2014-08-29 04:06:30 +00:00
using MediaBrowser.Model.Entities;
using System;
using System.IO;
using System.Linq;
namespace MediaBrowser.Server.Implementations.Library.Resolvers
{
public class PhotoAlbumResolver : FolderResolver<PhotoAlbum>
{
2015-04-08 14:38:02 +00:00
private readonly IImageProcessor _imageProcessor;
public PhotoAlbumResolver(IImageProcessor imageProcessor)
{
_imageProcessor = imageProcessor;
}
2014-08-29 04:06:30 +00: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-20 06:06:27 +00:00
if (args.IsDirectory && string.Equals(args.GetCollectionType(), CollectionType.Photos, StringComparison.OrdinalIgnoreCase))
2014-08-29 04:06:30 +00:00
{
if (HasPhotos(args))
{
return new PhotoAlbum
{
Path = args.Path
};
}
}
return null;
}
2015-04-08 14:38:02 +00:00
private bool HasPhotos(ItemResolveArgs args)
2014-08-29 04:06:30 +00:00
{
2016-10-25 19:02:04 +00:00
return args.FileSystemChildren.Any(i => (!i.IsDirectory) && PhotoResolver.IsImageFile(i.FullName, _imageProcessor));
2014-08-29 04:06:30 +00:00
}
2014-12-20 06:06:27 +00:00
public override ResolverPriority Priority
{
get
{
// Behind special folder resolver
return ResolverPriority.Second;
}
}
2014-08-29 04:06:30 +00:00
}
}