fixes #857 - Support album subfolders
This commit is contained in:
parent
be5d7641bc
commit
b87f759460
|
@ -71,6 +71,23 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||||
/// <value>The tags.</value>
|
/// <value>The tags.</value>
|
||||||
public List<string> Tags { get; set; }
|
public List<string> Tags { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the tracks.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The tracks.</value>
|
||||||
|
public IEnumerable<Audio> Tracks
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return RecursiveChildren.OfType<Audio>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IEnumerable<BaseItem> GetEligibleChildrenForRecursiveChildren(User user)
|
||||||
|
{
|
||||||
|
return Tracks;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Songs will group into us so don't also include us in the index
|
/// Songs will group into us so don't also include us in the index
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -67,7 +67,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||||
/// <returns><c>true</c> if [is music album] [the specified data]; otherwise, <c>false</c>.</returns>
|
/// <returns><c>true</c> if [is music album] [the specified data]; otherwise, <c>false</c>.</returns>
|
||||||
public static bool IsMusicAlbum(string path, IDirectoryService directoryService)
|
public static bool IsMusicAlbum(string path, IDirectoryService directoryService)
|
||||||
{
|
{
|
||||||
return ContainsMusic(directoryService.GetFileSystemEntries(path));
|
return ContainsMusic(directoryService.GetFileSystemEntries(path), true, directoryService);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -81,7 +81,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||||
if (args.IsDirectory)
|
if (args.IsDirectory)
|
||||||
{
|
{
|
||||||
//if (args.Parent is MusicArtist) return true; //saves us from testing children twice
|
//if (args.Parent is MusicArtist) return true; //saves us from testing children twice
|
||||||
if (ContainsMusic(args.FileSystemChildren)) return true;
|
if (ContainsMusic(args.FileSystemChildren, true, args.DirectoryService)) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -91,18 +91,26 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||||
/// Determine if the supplied list contains what we should consider music
|
/// Determine if the supplied list contains what we should consider music
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="list">The list.</param>
|
/// <param name="list">The list.</param>
|
||||||
|
/// <param name="allowSubfolders">if set to <c>true</c> [allow subfolders].</param>
|
||||||
|
/// <param name="directoryService">The directory service.</param>
|
||||||
/// <returns><c>true</c> if the specified list contains music; otherwise, <c>false</c>.</returns>
|
/// <returns><c>true</c> if the specified list contains music; otherwise, <c>false</c>.</returns>
|
||||||
private static bool ContainsMusic(IEnumerable<FileSystemInfo> list)
|
private static bool ContainsMusic(IEnumerable<FileSystemInfo> list, bool allowSubfolders, IDirectoryService directoryService)
|
||||||
{
|
{
|
||||||
// If list contains at least 2 audio files or at least one and no video files consider it to contain music
|
// If list contains at least 2 audio files or at least one and no video files consider it to contain music
|
||||||
var foundAudio = 0;
|
var foundAudio = 0;
|
||||||
|
|
||||||
foreach (var fileSystemInfo in list)
|
foreach (var fileSystemInfo in list)
|
||||||
{
|
{
|
||||||
// TODO: Support disc 1, disc 2, etc
|
|
||||||
if ((fileSystemInfo.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
|
if ((fileSystemInfo.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
|
||||||
{
|
{
|
||||||
continue;
|
if (allowSubfolders && IsAlbumSubfolder(fileSystemInfo, directoryService))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!IsAdditionalSubfolderAllowed(fileSystemInfo))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var fullName = fileSystemInfo.FullName;
|
var fullName = fileSystemInfo.FullName;
|
||||||
|
@ -129,5 +137,28 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||||
// or a single audio file and no video files
|
// or a single audio file and no video files
|
||||||
return foundAudio > 0;
|
return foundAudio > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool IsAlbumSubfolder(FileSystemInfo directory, IDirectoryService directoryService)
|
||||||
|
{
|
||||||
|
var path = directory.FullName;
|
||||||
|
|
||||||
|
if (IsMultiDiscFolder(path))
|
||||||
|
{
|
||||||
|
return ContainsMusic(directoryService.GetFileSystemEntries(path), false, directoryService);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsMultiDiscFolder(string path)
|
||||||
|
{
|
||||||
|
return EntityResolutionHelper.IsMultiPartFolder(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsAdditionalSubfolderAllowed(FileSystemInfo directory)
|
||||||
|
{
|
||||||
|
// TOOD: allow some metadata folders like extrafanart, extrathumbs
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user