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

50 lines
1.5 KiB
C#
Raw Normal View History

2014-08-29 04:06:30 +00:00
using MediaBrowser.Controller.Entities;
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>
{
/// <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;
}
private static bool HasPhotos(ItemResolveArgs args)
{
return args.FileSystemChildren.Any(i => ((i.Attributes & FileAttributes.Directory) != FileAttributes.Directory) && PhotoResolver.IsImageFile(i.FullName));
}
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
}
}