3.2.36.11
This commit is contained in:
parent
9f46122d91
commit
b5ab7776f1
|
@ -4,19 +4,26 @@ using MediaBrowser.Model.Entities;
|
||||||
using System;
|
using System;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using MediaBrowser.Controller.Providers;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using MediaBrowser.Model.IO;
|
||||||
|
using MediaBrowser.Model.Extensions;
|
||||||
|
using Emby.Naming.Video;
|
||||||
|
using Emby.Naming.AudioBook;
|
||||||
|
|
||||||
namespace Emby.Server.Implementations.Library.Resolvers.Audio
|
namespace Emby.Server.Implementations.Library.Resolvers.Audio
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class AudioResolver
|
/// Class AudioResolver
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class AudioResolver : ItemResolver<MediaBrowser.Controller.Entities.Audio.Audio>
|
public class AudioResolver : ItemResolver<MediaBrowser.Controller.Entities.Audio.Audio>, IMultiItemResolver
|
||||||
{
|
{
|
||||||
private readonly ILibraryManager _libraryManager;
|
private readonly ILibraryManager LibraryManager;
|
||||||
|
|
||||||
public AudioResolver(ILibraryManager libraryManager)
|
public AudioResolver(ILibraryManager libraryManager)
|
||||||
{
|
{
|
||||||
_libraryManager = libraryManager;
|
LibraryManager = libraryManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -28,6 +35,37 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
|
||||||
get { return ResolverPriority.Last; }
|
get { return ResolverPriority.Last; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MultiItemResolverResult ResolveMultiple(Folder parent,
|
||||||
|
List<FileSystemMetadata> files,
|
||||||
|
string collectionType,
|
||||||
|
IDirectoryService directoryService)
|
||||||
|
{
|
||||||
|
var result = ResolveMultipleInternal(parent, files, collectionType, directoryService);
|
||||||
|
|
||||||
|
if (result != null)
|
||||||
|
{
|
||||||
|
foreach (var item in result.Items)
|
||||||
|
{
|
||||||
|
SetInitialItemValues((MediaBrowser.Controller.Entities.Audio.Audio)item, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private MultiItemResolverResult ResolveMultipleInternal(Folder parent,
|
||||||
|
List<FileSystemMetadata> files,
|
||||||
|
string collectionType,
|
||||||
|
IDirectoryService directoryService)
|
||||||
|
{
|
||||||
|
if (string.Equals(collectionType, CollectionType.Books, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return ResolveMultipleAudio<AudioBook>(parent, files, directoryService, false, collectionType, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resolves the specified args.
|
/// Resolves the specified args.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -37,46 +75,193 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
|
||||||
{
|
{
|
||||||
// Return audio if the path is a file and has a matching extension
|
// Return audio if the path is a file and has a matching extension
|
||||||
|
|
||||||
if (!args.IsDirectory)
|
var libraryOptions = args.GetLibraryOptions();
|
||||||
|
var collectionType = args.GetCollectionType();
|
||||||
|
|
||||||
|
var isBooksCollectionType = string.Equals(collectionType, CollectionType.Books, StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
if (args.IsDirectory)
|
||||||
{
|
{
|
||||||
var libraryOptions = args.GetLibraryOptions();
|
if (!isBooksCollectionType)
|
||||||
|
|
||||||
if (_libraryManager.IsAudioFile(args.Path, libraryOptions))
|
|
||||||
{
|
{
|
||||||
if (string.Equals(Path.GetExtension(args.Path), ".cue", StringComparison.OrdinalIgnoreCase))
|
return null;
|
||||||
{
|
|
||||||
// if audio file exists of same name, return null
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var collectionType = args.GetCollectionType();
|
|
||||||
|
|
||||||
var isMixed = string.IsNullOrWhiteSpace(collectionType);
|
|
||||||
|
|
||||||
// For conflicting extensions, give priority to videos
|
|
||||||
if (isMixed && _libraryManager.IsVideoFile(args.Path, libraryOptions))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var isStandalone = args.Parent == null;
|
|
||||||
|
|
||||||
if (isStandalone ||
|
|
||||||
string.Equals(collectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase) ||
|
|
||||||
isMixed)
|
|
||||||
{
|
|
||||||
return new MediaBrowser.Controller.Entities.Audio.Audio();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.Equals(collectionType, CollectionType.Books, StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
return new AudioBook();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var files = args.FileSystemChildren
|
||||||
|
.Where(i => !LibraryManager.IgnoreFile(i, args.Parent))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
if (isBooksCollectionType)
|
||||||
|
{
|
||||||
|
return FindAudio<AudioBook>(args, args.Path, args.Parent, files, args.DirectoryService, collectionType, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LibraryManager.IsAudioFile(args.Path, libraryOptions))
|
||||||
|
{
|
||||||
|
if (string.Equals(Path.GetExtension(args.Path), ".cue", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
// if audio file exists of same name, return null
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var isMixedCollectionType = string.IsNullOrWhiteSpace(collectionType);
|
||||||
|
|
||||||
|
// For conflicting extensions, give priority to videos
|
||||||
|
if (isMixedCollectionType && LibraryManager.IsVideoFile(args.Path, libraryOptions))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
MediaBrowser.Controller.Entities.Audio.Audio item = null;
|
||||||
|
|
||||||
|
var isMusicCollectionType = string.Equals(collectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
// Use regular audio type for mixed libraries, owned items and music
|
||||||
|
if (isMixedCollectionType ||
|
||||||
|
args.Parent == null ||
|
||||||
|
isMusicCollectionType)
|
||||||
|
{
|
||||||
|
item = new MediaBrowser.Controller.Entities.Audio.Audio();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (isBooksCollectionType)
|
||||||
|
{
|
||||||
|
item = new AudioBook();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
item.IsInMixedFolder = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private T FindAudio<T>(ItemResolveArgs args, string path, Folder parent, List<FileSystemMetadata> fileSystemEntries, IDirectoryService directoryService, string collectionType, bool parseName)
|
||||||
|
where T : MediaBrowser.Controller.Entities.Audio.Audio, new()
|
||||||
|
{
|
||||||
|
var multiDiscFolders = new List<FileSystemMetadata>();
|
||||||
|
|
||||||
|
var libraryOptions = args.GetLibraryOptions();
|
||||||
|
var filesFromOtherItems = new List<FileSystemMetadata>();
|
||||||
|
|
||||||
|
// TODO: Allow GetMultiDiscMovie in here
|
||||||
|
var supportsMultiVersion = false;
|
||||||
|
|
||||||
|
var result = ResolveMultipleAudio<T>(parent, fileSystemEntries, directoryService, supportsMultiVersion, collectionType, parseName) ??
|
||||||
|
new MultiItemResolverResult();
|
||||||
|
|
||||||
|
if (result.Items.Count == 1)
|
||||||
|
{
|
||||||
|
var videoPath = result.Items[0].Path;
|
||||||
|
|
||||||
|
// If we were supporting this we'd be checking filesFromOtherItems
|
||||||
|
var hasOtherItems = false;
|
||||||
|
|
||||||
|
if (!hasOtherItems)
|
||||||
|
{
|
||||||
|
var item = (T)result.Items[0];
|
||||||
|
item.IsInMixedFolder = false;
|
||||||
|
item.Name = Path.GetFileName(item.ContainingFolderPath);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.Items.Count == 0 && multiDiscFolders.Count > 0)
|
||||||
|
{
|
||||||
|
//return GetMultiDiscAudio<T>(multiDiscFolders, directoryService);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private MultiItemResolverResult ResolveMultipleAudio<T>(Folder parent, IEnumerable<FileSystemMetadata> fileSystemEntries, IDirectoryService directoryService, bool suppportMultiEditions, string collectionType, bool parseName)
|
||||||
|
where T : MediaBrowser.Controller.Entities.Audio.Audio, new()
|
||||||
|
{
|
||||||
|
var files = new List<FileSystemMetadata>();
|
||||||
|
var items = new List<BaseItem>();
|
||||||
|
var leftOver = new List<FileSystemMetadata>();
|
||||||
|
|
||||||
|
// Loop through each child file/folder and see if we find a video
|
||||||
|
foreach (var child in fileSystemEntries)
|
||||||
|
{
|
||||||
|
if (child.IsDirectory)
|
||||||
|
{
|
||||||
|
leftOver.Add(child);
|
||||||
|
}
|
||||||
|
else if (IsIgnored(child.Name))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
files.Add(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var namingOptions = ((LibraryManager)LibraryManager).GetNamingOptions();
|
||||||
|
|
||||||
|
var resolver = new AudioBookListResolver(namingOptions);
|
||||||
|
var resolverResult = resolver.Resolve(files).ToList();
|
||||||
|
|
||||||
|
var result = new MultiItemResolverResult
|
||||||
|
{
|
||||||
|
ExtraFiles = leftOver,
|
||||||
|
Items = items
|
||||||
|
};
|
||||||
|
|
||||||
|
var isInMixedFolder = resolverResult.Count > 1 || (parent != null && parent.IsTopParent);
|
||||||
|
|
||||||
|
foreach (var resolvedItem in resolverResult)
|
||||||
|
{
|
||||||
|
var firstMedia = resolvedItem.Files.First();
|
||||||
|
|
||||||
|
var libraryItem = new T
|
||||||
|
{
|
||||||
|
Path = firstMedia.Path,
|
||||||
|
IsInMixedFolder = isInMixedFolder,
|
||||||
|
//ProductionYear = resolvedItem.Year,
|
||||||
|
Name = parseName ?
|
||||||
|
resolvedItem.Name :
|
||||||
|
Path.GetFileNameWithoutExtension(firstMedia.Path),
|
||||||
|
//AdditionalParts = resolvedItem.Files.Skip(1).Select(i => i.Path).ToArray(),
|
||||||
|
//LocalAlternateVersions = resolvedItem.AlternateVersions.Select(i => i.Path).ToArray()
|
||||||
|
};
|
||||||
|
|
||||||
|
result.Items.Add(libraryItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
result.ExtraFiles.AddRange(files.Where(i => !ContainsFile(resolverResult, i)));
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool ContainsFile(List<AudioBookInfo> result, FileSystemMetadata file)
|
||||||
|
{
|
||||||
|
return result.Any(i => ContainsFile(i, file));
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool ContainsFile(AudioBookInfo result, FileSystemMetadata file)
|
||||||
|
{
|
||||||
|
return result.Files.Any(i => ContainsFile(i, file)) ||
|
||||||
|
result.AlternateVersions.Any(i => ContainsFile(i, file)) ||
|
||||||
|
result.Extras.Any(i => ContainsFile(i, file));
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool ContainsFile(AudioBookFileInfo result, FileSystemMetadata file)
|
||||||
|
{
|
||||||
|
return string.Equals(result.Path, file.FullName, StringComparison.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsIgnored(string filename)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,14 +202,14 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
|
||||||
{
|
{
|
||||||
var collectionType = args.GetCollectionType();
|
var collectionType = args.GetCollectionType();
|
||||||
|
|
||||||
if (IsInvalid(args.Parent, collectionType))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find movies with their own folders
|
// Find movies with their own folders
|
||||||
if (args.IsDirectory)
|
if (args.IsDirectory)
|
||||||
{
|
{
|
||||||
|
if (IsInvalid(args.Parent, collectionType))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var files = args.FileSystemChildren
|
var files = args.FileSystemChildren
|
||||||
.Where(i => !LibraryManager.IgnoreFile(i, args.Parent))
|
.Where(i => !LibraryManager.IgnoreFile(i, args.Parent))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
@ -251,8 +251,13 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Owned items will be caught by the plain video resolver
|
// Handle owned items
|
||||||
if (args.Parent == null)
|
if (args.Parent == null)
|
||||||
|
{
|
||||||
|
return base.Resolve(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsInvalid(args.Parent, collectionType))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -528,6 +533,15 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
|
||||||
return returnVideo;
|
return returnVideo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string[] ValidCollectionTypes = new[]
|
||||||
|
{
|
||||||
|
CollectionType.Movies,
|
||||||
|
CollectionType.HomeVideos,
|
||||||
|
CollectionType.MusicVideos,
|
||||||
|
CollectionType.Movies,
|
||||||
|
CollectionType.Photos
|
||||||
|
};
|
||||||
|
|
||||||
private bool IsInvalid(Folder parent, string collectionType)
|
private bool IsInvalid(Folder parent, string collectionType)
|
||||||
{
|
{
|
||||||
if (parent != null)
|
if (parent != null)
|
||||||
|
@ -538,21 +552,12 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var validCollectionTypes = new[]
|
|
||||||
{
|
|
||||||
CollectionType.Movies,
|
|
||||||
CollectionType.HomeVideos,
|
|
||||||
CollectionType.MusicVideos,
|
|
||||||
CollectionType.Movies,
|
|
||||||
CollectionType.Photos
|
|
||||||
};
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(collectionType))
|
if (string.IsNullOrWhiteSpace(collectionType))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return !validCollectionTypes.Contains(collectionType, StringComparer.OrdinalIgnoreCase);
|
return !ValidCollectionTypes.Contains(collectionType, StringComparer.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IImageProcessor _imageProcessor;
|
private IImageProcessor _imageProcessor;
|
||||||
|
|
|
@ -5,36 +5,6 @@ using MediaBrowser.Model.IO;
|
||||||
|
|
||||||
namespace Emby.Server.Implementations.Library.Resolvers
|
namespace Emby.Server.Implementations.Library.Resolvers
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Resolves a Path into a Video
|
|
||||||
/// </summary>
|
|
||||||
public class VideoResolver : BaseVideoResolver<Video>
|
|
||||||
{
|
|
||||||
protected override Video Resolve(ItemResolveArgs args)
|
|
||||||
{
|
|
||||||
if (args.Parent != null)
|
|
||||||
{
|
|
||||||
// The movie resolver will handle this
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return base.Resolve(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the priority.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The priority.</value>
|
|
||||||
public override ResolverPriority Priority
|
|
||||||
{
|
|
||||||
get { return ResolverPriority.Last; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public VideoResolver(ILibraryManager libraryManager, IFileSystem fileSystem) : base(libraryManager, fileSystem)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class GenericVideoResolver<T> : BaseVideoResolver<T>
|
public class GenericVideoResolver<T> : BaseVideoResolver<T>
|
||||||
where T : Video, new ()
|
where T : Video, new ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
"Artists": "Artistas",
|
"Artists": "Artistas",
|
||||||
"Folders": "Carpetas",
|
"Folders": "Carpetas",
|
||||||
"Songs": "Canciones",
|
"Songs": "Canciones",
|
||||||
"TvShows": "TV Shows",
|
"TvShows": "Programas de TV",
|
||||||
"Shows": "Programas",
|
"Shows": "Programas",
|
||||||
"Genres": "G\u00e9neros",
|
"Genres": "G\u00e9neros",
|
||||||
"NameSeasonNumber": "Temporada {0}",
|
"NameSeasonNumber": "Temporada {0}",
|
||||||
|
|
|
@ -126,7 +126,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
var providers = GetProviders(item, refreshOptions, isFirstRefresh, requiresRefresh)
|
var providers = GetProviders(item, refreshOptions, isFirstRefresh, requiresRefresh)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
if (providers.Count > 0 || isFirstRefresh)
|
if (providers.Count > 0 || isFirstRefresh || requiresRefresh)
|
||||||
{
|
{
|
||||||
if (item.BeforeMetadataRefresh())
|
if (item.BeforeMetadataRefresh())
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace MediaBrowser.Server.Startup.Common
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger.Error("Skia not available. Will try next image processor. {0}", ex.Message);
|
logger.Info("Skia not available. Will try next image processor. {0}", ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -41,7 +41,7 @@ namespace MediaBrowser.Server.Startup.Common
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
logger.Error("ImageMagick not available. Will try next image processor.");
|
logger.Info("ImageMagick not available. Will try next image processor.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
[assembly: AssemblyVersion("3.2.36.10")]
|
[assembly: AssemblyVersion("3.2.36.11")]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user