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

42 lines
1.4 KiB
C#
Raw Normal View History

2014-08-28 21:06:30 -07:00
using MediaBrowser.Controller.Entities;
2014-02-12 22:11:54 -07:00
using MediaBrowser.Controller.Library;
2014-08-28 21:06:30 -07:00
using MediaBrowser.Model.Entities;
2014-02-12 22:11:54 -07:00
using System;
2014-08-28 21:06:30 -07:00
using System.IO;
2014-02-12 22:11:54 -07:00
using System.Linq;
namespace MediaBrowser.Server.Implementations.Library.Resolvers
{
public class PhotoResolver : ItemResolver<Photo>
{
/// <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
2014-08-28 21:06:30 -07:00
if (!args.IsDirectory && IsImageFile(args.Path) && string.Equals(args.GetCollectionType(), CollectionType.Photos, StringComparison.OrdinalIgnoreCase))
2014-02-12 22:11:54 -07:00
{
return new Photo
{
Path = args.Path
};
}
return null;
}
2014-02-19 09:24:06 -07:00
protected static string[] ImageExtensions = { ".tiff", ".jpeg", ".jpg", ".png", ".aiff" };
2014-08-28 21:06:30 -07:00
internal static bool IsImageFile(string path)
2014-02-12 22:11:54 -07:00
{
2014-08-28 21:06:30 -07:00
var filename = Path.GetFileName(path);
return !string.Equals(filename, "folder.jpg", StringComparison.OrdinalIgnoreCase)
&& ImageExtensions.Contains(Path.GetExtension(path) ?? string.Empty, StringComparer.OrdinalIgnoreCase);
2014-02-12 22:11:54 -07:00
}
}
}