mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-17 19:54:47 +01:00
added drawing project
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Drawing;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Resolvers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
@@ -10,6 +11,12 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
|
||||
{
|
||||
public class PhotoAlbumResolver : FolderResolver<PhotoAlbum>
|
||||
{
|
||||
private readonly IImageProcessor _imageProcessor;
|
||||
public PhotoAlbumResolver(IImageProcessor imageProcessor)
|
||||
{
|
||||
_imageProcessor = imageProcessor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the specified args.
|
||||
/// </summary>
|
||||
@@ -32,9 +39,9 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
|
||||
return null;
|
||||
}
|
||||
|
||||
private static bool HasPhotos(ItemResolveArgs args)
|
||||
private bool HasPhotos(ItemResolveArgs args)
|
||||
{
|
||||
return args.FileSystemChildren.Any(i => ((i.Attributes & FileAttributes.Directory) != FileAttributes.Directory) && PhotoResolver.IsImageFile(i.FullName));
|
||||
return args.FileSystemChildren.Any(i => ((i.Attributes & FileAttributes.Directory) != FileAttributes.Directory) && PhotoResolver.IsImageFile(i.FullName, _imageProcessor));
|
||||
}
|
||||
|
||||
public override ResolverPriority Priority
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Drawing;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
@@ -9,6 +10,12 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
|
||||
{
|
||||
public class PhotoResolver : ItemResolver<Photo>
|
||||
{
|
||||
private readonly IImageProcessor _imageProcessor;
|
||||
public PhotoResolver(IImageProcessor imageProcessor)
|
||||
{
|
||||
_imageProcessor = imageProcessor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the specified args.
|
||||
/// </summary>
|
||||
@@ -19,7 +26,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
|
||||
// Must be an image file within a photo collection
|
||||
if (string.Equals(args.GetCollectionType(), CollectionType.Photos, StringComparison.OrdinalIgnoreCase) &&
|
||||
!args.IsDirectory &&
|
||||
IsImageFile(args.Path))
|
||||
IsImageFile(args.Path, _imageProcessor))
|
||||
{
|
||||
return new Photo
|
||||
{
|
||||
@@ -30,9 +37,6 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
|
||||
return null;
|
||||
}
|
||||
|
||||
// Some common file name extensions for RAW picture files include: .cr2, .crw, .dng, .nef, .orf, .rw2, .pef, .arw, .sr2, .srf, and .tif.
|
||||
protected static string[] ImageExtensions = { ".tiff", ".jpeg", ".jpg", ".png", ".aiff", ".cr2", ".crw", ".dng", ".nef", ".orf", ".pef", ".arw", ".webp" };
|
||||
|
||||
private static readonly string[] IgnoreFiles =
|
||||
{
|
||||
"folder",
|
||||
@@ -43,12 +47,12 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
|
||||
"poster"
|
||||
};
|
||||
|
||||
internal static bool IsImageFile(string path)
|
||||
internal static bool IsImageFile(string path, IImageProcessor imageProcessor)
|
||||
{
|
||||
var filename = Path.GetFileNameWithoutExtension(path) ?? string.Empty;
|
||||
|
||||
return !IgnoreFiles.Contains(filename, StringComparer.OrdinalIgnoreCase)
|
||||
&& ImageExtensions.Contains(Path.GetExtension(path) ?? string.Empty, StringComparer.OrdinalIgnoreCase);
|
||||
&& imageProcessor.SupportedInputFormats.Contains((Path.GetExtension(path) ?? string.Empty).TrimStart('.'), StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user