aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Library/Resolvers
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/Library/Resolvers')
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs10
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs72
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs49
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/PhotoResolver.cs33
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs4
5 files changed, 116 insertions, 52 deletions
diff --git a/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs
index 4852c3c6a..7aa4c299f 100644
--- a/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs
@@ -12,7 +12,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Books
/// </summary>
public class BookResolver : MediaBrowser.Controller.Resolvers.ItemResolver<Book>
{
- private readonly string[] _validExtensions = {".pdf", ".epub", ".mobi", ".cbr", ".cbz"};
+ private readonly string[] _validExtensions = { ".pdf", ".epub", ".mobi", ".cbr", ".cbz", ".azw3" };
/// <summary>
///
@@ -26,7 +26,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Books
// Only process items that are in a collection folder containing books
if (!string.Equals(collectionType, CollectionType.Books, StringComparison.OrdinalIgnoreCase))
return null;
-
+
if (args.IsDirectory)
{
return GetBook(args);
@@ -69,9 +69,9 @@ namespace Emby.Server.Implementations.Library.Resolvers.Books
return null;
return new Book
- {
- Path = bookFiles[0].FullName
- };
+ {
+ Path = bookFiles[0].FullName
+ };
}
}
}
diff --git a/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
index cd1264754..94cafa3e2 100644
--- a/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
@@ -11,7 +11,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
-
+using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.IO;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging;
@@ -69,13 +69,13 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
if (string.Equals(collectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase))
{
- return ResolveVideos<MusicVideo>(parent, files, directoryService, true, collectionType);
+ return ResolveVideos<MusicVideo>(parent, files, directoryService, true, collectionType, false);
}
if (string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase) ||
string.Equals(collectionType, CollectionType.Photos, StringComparison.OrdinalIgnoreCase))
{
- return ResolveVideos<Video>(parent, files, directoryService, false, collectionType);
+ return ResolveVideos<Video>(parent, files, directoryService, false, collectionType, false);
}
if (string.IsNullOrWhiteSpace(collectionType))
@@ -83,7 +83,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
// Owned items should just use the plain video type
if (parent == null)
{
- return ResolveVideos<Video>(parent, files, directoryService, false, collectionType);
+ return ResolveVideos<Video>(parent, files, directoryService, false, collectionType, false);
}
if (parent is Series || parent.GetParents().OfType<Series>().Any())
@@ -91,18 +91,18 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
return null;
}
- return ResolveVideos<Movie>(parent, files, directoryService, false, collectionType);
+ return ResolveVideos<Movie>(parent, files, directoryService, false, collectionType, true);
}
if (string.Equals(collectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase))
{
- return ResolveVideos<Movie>(parent, files, directoryService, true, collectionType);
+ return ResolveVideos<Movie>(parent, files, directoryService, true, collectionType, true);
}
return null;
}
- private MultiItemResolverResult ResolveVideos<T>(Folder parent, IEnumerable<FileSystemMetadata> fileSystemEntries, IDirectoryService directoryService, bool suppportMultiEditions, string collectionType)
+ private MultiItemResolverResult ResolveVideos<T>(Folder parent, IEnumerable<FileSystemMetadata> fileSystemEntries, IDirectoryService directoryService, bool suppportMultiEditions, string collectionType, bool parseName)
where T : Video, new()
{
var files = new List<FileSystemMetadata>();
@@ -147,7 +147,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
Items = videos
};
- var isInMixedFolder = resolverResult.Count > 1;
+ var isInMixedFolder = resolverResult.Count > 1 || (parent != null && parent.IsTopParent);
foreach (var video in resolverResult)
{
@@ -158,7 +158,9 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
Path = video.Files[0].Path,
IsInMixedFolder = isInMixedFolder,
ProductionYear = video.Year,
- Name = video.Name,
+ Name = parseName ?
+ video.Name :
+ Path.GetFileName(video.Files[0].Path),
AdditionalParts = video.Files.Skip(1).Select(i => i.Path).ToArray(),
LocalAlternateVersions = video.AlternateVersions.Select(i => i.Path).ToArray()
};
@@ -214,12 +216,12 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
if (string.Equals(collectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase))
{
- return FindMovie<MusicVideo>(args.Path, args.Parent, files, args.DirectoryService, collectionType, true);
+ return FindMovie<MusicVideo>(args, args.Path, args.Parent, files, args.DirectoryService, collectionType, false);
}
if (string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase))
{
- return FindMovie<Video>(args.Path, args.Parent, files, args.DirectoryService, collectionType, false);
+ return FindMovie<Video>(args, args.Path, args.Parent, files, args.DirectoryService, collectionType, false);
}
if (string.IsNullOrEmpty(collectionType))
@@ -237,13 +239,13 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
}
{
- return FindMovie<Movie>(args.Path, args.Parent, files, args.DirectoryService, collectionType, true);
+ return FindMovie<Movie>(args, args.Path, args.Parent, files, args.DirectoryService, collectionType, true);
}
}
if (string.Equals(collectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase))
{
- return FindMovie<Movie>(args.Path, args.Parent, files, args.DirectoryService, collectionType, true);
+ return FindMovie<Movie>(args, args.Path, args.Parent, files, args.DirectoryService, collectionType, true);
}
return null;
@@ -359,11 +361,15 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns>Movie.</returns>
- private T FindMovie<T>(string path, Folder parent, List<FileSystemMetadata> fileSystemEntries, IDirectoryService directoryService, string collectionType, bool allowFilesAsFolders)
+ private T FindMovie<T>(ItemResolveArgs args, string path, Folder parent, List<FileSystemMetadata> fileSystemEntries, IDirectoryService directoryService, string collectionType, bool parseName)
where T : Video, new()
{
var multiDiscFolders = new List<FileSystemMetadata>();
+ var libraryOptions = args.GetLibraryOptions();
+ var supportPhotos = string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase) && libraryOptions.EnablePhotos;
+ var photos = new List<FileSystemMetadata>();
+
// Search for a folder rip
foreach (var child in fileSystemEntries)
{
@@ -404,30 +410,37 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
Set3DFormat(movie);
return movie;
}
+ else if (supportPhotos && !child.IsHidden && PhotoResolver.IsImageFile(child.FullName, _imageProcessor))
+ {
+ photos.Add(child);
+ }
}
- if (allowFilesAsFolders)
- {
- // TODO: Allow GetMultiDiscMovie in here
- var supportsMultiVersion = !string.Equals(collectionType, CollectionType.HomeVideos) &&
- !string.Equals(collectionType, CollectionType.Photos) &&
- !string.Equals(collectionType, CollectionType.MusicVideos);
+ // TODO: Allow GetMultiDiscMovie in here
+ var supportsMultiVersion = !string.Equals(collectionType, CollectionType.HomeVideos) &&
+ !string.Equals(collectionType, CollectionType.Photos) &&
+ !string.Equals(collectionType, CollectionType.MusicVideos);
+
+ var result = ResolveVideos<T>(parent, fileSystemEntries, directoryService, supportsMultiVersion, collectionType, parseName) ??
+ new MultiItemResolverResult();
- var result = ResolveVideos<T>(parent, fileSystemEntries, directoryService, supportsMultiVersion, collectionType) ??
- new MultiItemResolverResult();
+ if (result.Items.Count == 1)
+ {
+ var videoPath = result.Items[0].Path;
+ var hasPhotos = photos.Any(i => !PhotoResolver.IsOwnedByResolvedMedia(LibraryManager, libraryOptions, videoPath, i.Name));
- if (result.Items.Count == 1)
+ if (!hasPhotos)
{
var movie = (T)result.Items[0];
movie.IsInMixedFolder = false;
movie.Name = Path.GetFileName(movie.ContainingFolderPath);
return movie;
}
+ }
- if (result.Items.Count == 0 && multiDiscFolders.Count > 0)
- {
- return GetMultiDiscMovie<T>(multiDiscFolders, directoryService);
- }
+ if (result.Items.Count == 0 && multiDiscFolders.Count > 0)
+ {
+ return GetMultiDiscMovie<T>(multiDiscFolders, directoryService);
}
return null;
@@ -542,8 +555,11 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
return !validCollectionTypes.Contains(collectionType, StringComparer.OrdinalIgnoreCase);
}
- public MovieResolver(ILibraryManager libraryManager, IFileSystem fileSystem) : base(libraryManager, fileSystem)
+ private IImageProcessor _imageProcessor;
+
+ public MovieResolver(ILibraryManager libraryManager, IFileSystem fileSystem, IImageProcessor imageProcessor) : base(libraryManager, fileSystem)
{
+ _imageProcessor = imageProcessor;
}
}
}
diff --git a/Emby.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs b/Emby.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs
index 3d7ede879..311abf14e 100644
--- a/Emby.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs
@@ -12,9 +12,12 @@ namespace Emby.Server.Implementations.Library.Resolvers
public class PhotoAlbumResolver : FolderResolver<PhotoAlbum>
{
private readonly IImageProcessor _imageProcessor;
- public PhotoAlbumResolver(IImageProcessor imageProcessor)
+ private ILibraryManager _libraryManager;
+
+ public PhotoAlbumResolver(IImageProcessor imageProcessor, ILibraryManager libraryManager)
{
_imageProcessor = imageProcessor;
+ _libraryManager = libraryManager;
}
/// <summary>
@@ -25,14 +28,21 @@ namespace Emby.Server.Implementations.Library.Resolvers
protected override PhotoAlbum Resolve(ItemResolveArgs args)
{
// Must be an image file within a photo collection
- if (args.IsDirectory && string.Equals(args.GetCollectionType(), CollectionType.Photos, StringComparison.OrdinalIgnoreCase))
+ if (args.IsDirectory)
{
- if (HasPhotos(args))
+ // 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))
{
- return new PhotoAlbum
+ if (HasPhotos(args))
{
- Path = args.Path
- };
+ return new PhotoAlbum
+ {
+ Path = args.Path
+ };
+ }
}
}
@@ -41,7 +51,32 @@ namespace Emby.Server.Implementations.Library.Resolvers
private bool HasPhotos(ItemResolveArgs args)
{
- return args.FileSystemChildren.Any(i => (!i.IsDirectory) && PhotoResolver.IsImageFile(i.FullName, _imageProcessor));
+ 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
diff --git a/Emby.Server.Implementations/Library/Resolvers/PhotoResolver.cs b/Emby.Server.Implementations/Library/Resolvers/PhotoResolver.cs
index 04312f277..48f5802a9 100644
--- a/Emby.Server.Implementations/Library/Resolvers/PhotoResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/PhotoResolver.cs
@@ -35,7 +35,6 @@ namespace Emby.Server.Implementations.Library.Resolvers
// 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))
{
@@ -44,9 +43,15 @@ namespace Emby.Server.Implementations.Library.Resolvers
var filename = Path.GetFileNameWithoutExtension(args.Path);
// Make sure the image doesn't belong to a video file
- if (_fileSystem.GetFilePaths(_fileSystem.GetDirectoryName(args.Path)).Any(i => IsOwnedByMedia(args.GetLibraryOptions(), i, filename)))
+ var files = args.DirectoryService.GetFiles(_fileSystem.GetDirectoryName(args.Path));
+ var libraryOptions = args.GetLibraryOptions();
+
+ foreach (var file in files)
{
- return null;
+ if (IsOwnedByMedia(_libraryManager, libraryOptions, file.FullName, filename))
+ {
+ return null;
+ }
}
return new Photo
@@ -60,14 +65,21 @@ namespace Emby.Server.Implementations.Library.Resolvers
return null;
}
- private bool IsOwnedByMedia(LibraryOptions libraryOptions, string file, string imageFilename)
+ internal static bool IsOwnedByMedia(ILibraryManager libraryManager, LibraryOptions libraryOptions, string file, string imageFilename)
{
- if (_libraryManager.IsVideoFile(file, libraryOptions))
+ if (libraryManager.IsVideoFile(file, libraryOptions))
{
- if (imageFilename.StartsWith(Path.GetFileNameWithoutExtension(file), StringComparison.OrdinalIgnoreCase))
- {
- return true;
- }
+ return IsOwnedByResolvedMedia(libraryManager, libraryOptions, file, imageFilename);
+ }
+
+ return false;
+ }
+
+ internal static bool IsOwnedByResolvedMedia(ILibraryManager libraryManager, LibraryOptions libraryOptions, string file, string imageFilename)
+ {
+ if (imageFilename.StartsWith(Path.GetFileNameWithoutExtension(file), StringComparison.OrdinalIgnoreCase))
+ {
+ return true;
}
return false;
@@ -81,7 +93,8 @@ namespace Emby.Server.Implementations.Library.Resolvers
"fanart",
"backdrop",
"poster",
- "cover"
+ "cover",
+ "logo"
};
internal static bool IsImageFile(string path, IImageProcessor imageProcessor)
diff --git a/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs b/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs
index a859d8ec8..a0ff29482 100644
--- a/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs
@@ -55,10 +55,10 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
if (season.IndexNumber.HasValue)
{
var seasonNumber = season.IndexNumber.Value;
-
+
season.Name = seasonNumber == 0 ?
args.LibraryOptions.SeasonZeroDisplayName :
- string.Format(_localization.GetLocalizedString("NameSeasonNumber"), seasonNumber.ToString(UsCulture));
+ string.Format(_localization.GetLocalizedString("NameSeasonNumber"), seasonNumber.ToString(UsCulture), args.GetLibraryOptions().PreferredMetadataLanguage);
}
return season;