diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-02-13 00:11:54 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-02-13 00:11:54 -0500 |
| commit | eec9e0482525c400e9dc7cb17bc000434adba105 (patch) | |
| tree | 73f51bc882804ff92b82d1e85a46a6cec10b6d51 /MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs | |
| parent | 9254c37d52af3d16ec9e46b3e211ecc7dc4f1617 (diff) | |
take photos into the core
Diffstat (limited to 'MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs new file mode 100644 index 000000000..35261dc3b --- /dev/null +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs @@ -0,0 +1,50 @@ +using MediaBrowser.Controller; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Library; +using System; +using System.Linq; + +namespace MediaBrowser.Server.Implementations.Library.Resolvers +{ + public class PhotoResolver : ItemResolver<Photo> + { + private readonly IServerApplicationPaths _applicationPaths; + + /// <summary> + /// Initializes a new instance of the <see cref="PhotoResolver" /> class. + /// </summary> + /// <param name="applicationPaths">The application paths.</param> + public PhotoResolver(IServerApplicationPaths applicationPaths) + { + _applicationPaths = applicationPaths; + } + + /// <summary> + /// Resolves the specified args. + /// </summary> + /// <param name="args">The args.</param> + /// <returns>Trailer.</returns> + protected override Photo Resolve(ItemResolveArgs args) + { + // Must be an image file within a photo collection + if (!args.IsDirectory && IsImageFile(args.Path) && string.Equals(args.GetCollectionType(), "photos", StringComparison.OrdinalIgnoreCase)) + { + return new Photo + { + Path = args.Path + }; + } + + return null; + } + + protected static string[] ImageExtensions = { ".tiff", ".jpg", ".png", ".aiff" }; + protected bool IsImageFile(string path) + { + return !path.EndsWith("folder.jpg", StringComparison.OrdinalIgnoreCase) + && !path.EndsWith("backdrop.jpg", StringComparison.OrdinalIgnoreCase) + && ImageExtensions.Any(p => path.EndsWith(p, StringComparison.OrdinalIgnoreCase)); + } + + } +} |
