update video resolver

This commit is contained in:
Luke Pulverenti 2016-10-17 12:40:43 -04:00
parent bba0c564c7
commit 716aef7e47

View File

@ -207,14 +207,18 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
// Find movies with their own folders // Find movies with their own folders
if (args.IsDirectory) if (args.IsDirectory)
{ {
var files = args.FileSystemChildren
.Where(i => !LibraryManager.IgnoreFile(i, args.Parent))
.ToList();
if (string.Equals(collectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase)) if (string.Equals(collectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase))
{ {
return null; return FindMovie<MusicVideo>(args.Path, args.Parent, files, args.DirectoryService, collectionType, false);
} }
if (string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase)) if (string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase))
{ {
return null; return FindMovie<Video>(args.Path, args.Parent, files, args.DirectoryService, collectionType, false);
} }
if (string.IsNullOrEmpty(collectionType)) if (string.IsNullOrEmpty(collectionType))
@ -222,6 +226,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
// Owned items will be caught by the plain video resolver // Owned items will be caught by the plain video resolver
if (args.Parent == null) if (args.Parent == null)
{ {
//return FindMovie<Video>(args.Path, args.Parent, files, args.DirectoryService, collectionType);
return null; return null;
} }
@ -231,21 +236,13 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
} }
{ {
var files = args.FileSystemChildren return FindMovie<Movie>(args.Path, args.Parent, files, args.DirectoryService, collectionType, true);
.Where(i => !LibraryManager.IgnoreFile(i, args.Parent))
.ToList();
return FindMovie<Movie>(args.Path, args.Parent, files, args.DirectoryService, collectionType);
} }
} }
if (string.Equals(collectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase)) if (string.Equals(collectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase))
{ {
var files = args.FileSystemChildren return FindMovie<Movie>(args.Path, args.Parent, files, args.DirectoryService, collectionType, true);
.Where(i => !LibraryManager.IgnoreFile(i, args.Parent))
.ToList();
return FindMovie<Movie>(args.Path, args.Parent, files, args.DirectoryService, collectionType);
} }
return null; return null;
@ -360,13 +357,8 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
/// Finds a movie based on a child file system entries /// Finds a movie based on a child file system entries
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
/// <param name="path">The path.</param>
/// <param name="parent">The parent.</param>
/// <param name="fileSystemEntries">The file system entries.</param>
/// <param name="directoryService">The directory service.</param>
/// <param name="collectionType">Type of the collection.</param>
/// <returns>Movie.</returns> /// <returns>Movie.</returns>
private T FindMovie<T>(string path, Folder parent, List<FileSystemMetadata> fileSystemEntries, IDirectoryService directoryService, string collectionType) private T FindMovie<T>(string path, Folder parent, List<FileSystemMetadata> fileSystemEntries, IDirectoryService directoryService, string collectionType, bool allowFilesAsFolders)
where T : Video, new() where T : Video, new()
{ {
var multiDiscFolders = new List<FileSystemMetadata>(); var multiDiscFolders = new List<FileSystemMetadata>();
@ -413,23 +405,27 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
} }
} }
var supportsMultiVersion = !string.Equals(collectionType, CollectionType.HomeVideos) && if (allowFilesAsFolders)
!string.Equals(collectionType, CollectionType.Photos) &&
!string.Equals(collectionType, CollectionType.MusicVideos);
var result = ResolveVideos<T>(parent, fileSystemEntries, directoryService, supportsMultiVersion);
if (result.Items.Count == 1)
{ {
var movie = (T)result.Items[0]; // TODO: Allow GetMultiDiscMovie in here
movie.IsInMixedFolder = false; var supportsMultiVersion = !string.Equals(collectionType, CollectionType.HomeVideos) &&
movie.Name = Path.GetFileName(movie.ContainingFolderPath); !string.Equals(collectionType, CollectionType.Photos) &&
return movie; !string.Equals(collectionType, CollectionType.MusicVideos);
}
if (result.Items.Count == 0 && multiDiscFolders.Count > 0) var result = ResolveVideos<T>(parent, fileSystemEntries, directoryService, supportsMultiVersion);
{
return GetMultiDiscMovie<T>(multiDiscFolders, directoryService); if (result.Items.Count == 1)
{
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);
}
} }
return null; return null;