From 18a7ddc2fa4644a10de0d9f72b3154ff4528be89 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 29 Aug 2014 00:06:30 -0400 Subject: add photo album --- .../Library/Resolvers/PhotoAlbumResolver.cs | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 MediaBrowser.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs (limited to 'MediaBrowser.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs') diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs new file mode 100644 index 0000000000..2fcfd70868 --- /dev/null +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs @@ -0,0 +1,39 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Library; +using MediaBrowser.Model.Entities; +using System; +using System.IO; +using System.Linq; + +namespace MediaBrowser.Server.Implementations.Library.Resolvers +{ + public class PhotoAlbumResolver : FolderResolver + { + /// + /// Resolves the specified args. + /// + /// The args. + /// Trailer. + protected override PhotoAlbum Resolve(ItemResolveArgs args) + { + // Must be an image file within a photo collection + if (!args.IsRoot && args.IsDirectory && string.Equals(args.GetCollectionType(), CollectionType.Photos, StringComparison.OrdinalIgnoreCase)) + { + if (HasPhotos(args)) + { + return new PhotoAlbum + { + Path = args.Path + }; + } + } + + return null; + } + + private static bool HasPhotos(ItemResolveArgs args) + { + return args.FileSystemChildren.Any(i => ((i.Attributes & FileAttributes.Directory) != FileAttributes.Directory) && PhotoResolver.IsImageFile(i.FullName)); + } + } +} -- cgit v1.2.3