|
|
@ -1,5 +1,8 @@
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Emby.Naming.Audio;
|
|
|
|
using Emby.Naming.Audio;
|
|
|
|
using MediaBrowser.Controller.Entities.Audio;
|
|
|
|
using MediaBrowser.Controller.Entities.Audio;
|
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
@ -113,22 +116,29 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
|
|
|
|
IFileSystem fileSystem,
|
|
|
|
IFileSystem fileSystem,
|
|
|
|
ILibraryManager libraryManager)
|
|
|
|
ILibraryManager libraryManager)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// check for audio files before digging down into directories
|
|
|
|
|
|
|
|
var foundAudioFile = list.Any(fileSystemInfo => !fileSystemInfo.IsDirectory && libraryManager.IsAudioFile(fileSystemInfo.FullName));
|
|
|
|
|
|
|
|
if (foundAudioFile)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// at least one audio file exists
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!allowSubfolders)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// not music since no audio file exists and we're not looking into subfolders
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var discSubfolderCount = 0;
|
|
|
|
var discSubfolderCount = 0;
|
|
|
|
var notMultiDisc = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var namingOptions = ((LibraryManager)_libraryManager).GetNamingOptions();
|
|
|
|
var namingOptions = ((LibraryManager)_libraryManager).GetNamingOptions();
|
|
|
|
var parser = new AlbumParser(namingOptions);
|
|
|
|
var parser = new AlbumParser(namingOptions);
|
|
|
|
foreach (var fileSystemInfo in list)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (fileSystemInfo.IsDirectory)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (allowSubfolders)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (notMultiDisc)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var directories = list.Where(fileSystemInfo => fileSystemInfo.IsDirectory);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var result = Parallel.ForEach(directories, (fileSystemInfo, state) =>
|
|
|
|
|
|
|
|
{
|
|
|
|
var path = fileSystemInfo.FullName;
|
|
|
|
var path = fileSystemInfo.FullName;
|
|
|
|
var hasMusic = ContainsMusic(directoryService.GetFileSystemEntries(path), false, directoryService, logger, fileSystem, libraryManager);
|
|
|
|
var hasMusic = ContainsMusic(directoryService.GetFileSystemEntries(path), false, directoryService, logger, fileSystem, libraryManager);
|
|
|
|
|
|
|
|
|
|
|
@ -137,28 +147,17 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
|
|
|
|
if (parser.IsMultiPart(path))
|
|
|
|
if (parser.IsMultiPart(path))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
logger.LogDebug("Found multi-disc folder: " + path);
|
|
|
|
logger.LogDebug("Found multi-disc folder: " + path);
|
|
|
|
discSubfolderCount++;
|
|
|
|
Interlocked.Increment(ref discSubfolderCount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// If there are folders underneath with music that are not multidisc, then this can't be a multi-disc album
|
|
|
|
// If there are folders underneath with music that are not multidisc, then this can't be a multi-disc album
|
|
|
|
notMultiDisc = true;
|
|
|
|
state.Stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var fullName = fileSystemInfo.FullName;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (libraryManager.IsAudioFile(fullName))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (notMultiDisc)
|
|
|
|
if (!result.IsCompleted)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|