|
|
|
@ -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;
|
|
|
|
@ -216,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, false);
|
|
|
|
|
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, false);
|
|
|
|
|
return FindMovie<Video>(args, args.Path, args.Parent, files, args.DirectoryService, collectionType, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(collectionType))
|
|
|
|
@ -239,13 +239,13 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
return FindMovie<Movie>(args.Path, args.Parent, files, args.DirectoryService, collectionType, true, 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, true);
|
|
|
|
|
return FindMovie<Movie>(args, args.Path, args.Parent, files, args.DirectoryService, collectionType, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
@ -361,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, bool parseName)
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
@ -406,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, parseName) ??
|
|
|
|
|
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;
|
|
|
|
@ -544,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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|