mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-07 03:48:06 +02:00
Add Argument*Exceptions now use proper nameof operators. Added exception messages to quite a few Argument*Exceptions. Fixed rethorwing to be proper syntax. Added a ton of null checkes. (This is only a start, there are about 500 places that need proper null handling) Added some TODOs to log certain exceptions. Fix sln again. Fixed all AssemblyInfo's and added proper copyright (where I could find them) We live in *current year*. Fixed the use of braces. Fixed a ton of properties, and made a fair amount of functions static that should be and can be static. Made more Methods that should be static static. You can now use static to find bad functions! Removed unused variable. And added one more proper XML comment.
84 lines
2.8 KiB
C#
84 lines
2.8 KiB
C#
using MediaBrowser.Controller.Drawing;
|
|
using MediaBrowser.Controller.Entities;
|
|
using MediaBrowser.Controller.Library;
|
|
using MediaBrowser.Controller.Resolvers;
|
|
using MediaBrowser.Model.Entities;
|
|
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
|
|
namespace Emby.Server.Implementations.Library.Resolvers
|
|
{
|
|
public class PhotoAlbumResolver : FolderResolver<PhotoAlbum>
|
|
{
|
|
private readonly IImageProcessor _imageProcessor;
|
|
private ILibraryManager _libraryManager;
|
|
|
|
public PhotoAlbumResolver(IImageProcessor imageProcessor, ILibraryManager libraryManager)
|
|
{
|
|
_imageProcessor = imageProcessor;
|
|
_libraryManager = libraryManager;
|
|
}
|
|
|
|
/// <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
|
|
if (args.IsDirectory)
|
|
{
|
|
// Must be an image file within a photo collection
|
|
var collectionType = args.GetCollectionType();
|
|
|
|
if (string.Equals(collectionType, CollectionType.Photos, StringComparison.OrdinalIgnoreCase) ||
|
|
(string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase) && args.GetLibraryOptions().EnablePhotos))
|
|
{
|
|
if (HasPhotos(args))
|
|
{
|
|
return new PhotoAlbum
|
|
{
|
|
Path = args.Path
|
|
};
|
|
}
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
private bool HasPhotos(ItemResolveArgs args)
|
|
{
|
|
var files = args.FileSystemChildren;
|
|
|
|
foreach (var file in files)
|
|
{
|
|
if (!file.IsDirectory && PhotoResolver.IsImageFile(file.FullName, _imageProcessor))
|
|
{
|
|
var libraryOptions = args.GetLibraryOptions();
|
|
var filename = file.Name;
|
|
var ownedByMedia = false;
|
|
|
|
foreach (var siblingFile in files)
|
|
{
|
|
if (PhotoResolver.IsOwnedByMedia(_libraryManager, libraryOptions, siblingFile.FullName, filename))
|
|
{
|
|
ownedByMedia = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!ownedByMedia)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public override ResolverPriority Priority => ResolverPriority.Second;
|
|
}
|
|
}
|