From 3eb4091808735858b01855d298226d239be464af Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 3 Nov 2016 02:37:52 -0400 Subject: move additional classes to new server lib --- .../Library/Resolvers/PhotoAlbumResolver.cs | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 Emby.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs (limited to 'Emby.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs') diff --git a/Emby.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs b/Emby.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs new file mode 100644 index 0000000000..3d7ede879f --- /dev/null +++ b/Emby.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs @@ -0,0 +1,56 @@ +using MediaBrowser.Controller.Drawing; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.Resolvers; +using MediaBrowser.Model.Entities; +using System; +using System.IO; +using System.Linq; + +namespace Emby.Server.Implementations.Library.Resolvers +{ + public class PhotoAlbumResolver : FolderResolver + { + private readonly IImageProcessor _imageProcessor; + public PhotoAlbumResolver(IImageProcessor imageProcessor) + { + _imageProcessor = imageProcessor; + } + + /// + /// Resolves the specified args. + /// + /// The args. + /// Trailer. + protected override PhotoAlbum Resolve(ItemResolveArgs args) + { + // Must be an image file within a photo collection + if (args.IsDirectory && string.Equals(args.GetCollectionType(), CollectionType.Photos, StringComparison.OrdinalIgnoreCase)) + { + if (HasPhotos(args)) + { + return new PhotoAlbum + { + Path = args.Path + }; + } + } + + return null; + } + + private bool HasPhotos(ItemResolveArgs args) + { + return args.FileSystemChildren.Any(i => (!i.IsDirectory) && PhotoResolver.IsImageFile(i.FullName, _imageProcessor)); + } + + public override ResolverPriority Priority + { + get + { + // Behind special folder resolver + return ResolverPriority.Second; + } + } + } +} -- cgit v1.2.3