diff --git a/Emby.Naming/AudioBook/AudioBookFileInfo.cs b/Emby.Naming/AudioBook/AudioBookFileInfo.cs index e5200416ee..862e396677 100644 --- a/Emby.Naming/AudioBook/AudioBookFileInfo.cs +++ b/Emby.Naming/AudioBook/AudioBookFileInfo.cs @@ -14,14 +14,12 @@ namespace Emby.Naming.AudioBook /// File type. /// Number of part this file represents. /// Number of chapter this file represents. - /// Indication if we are looking at file or directory. - public AudioBookFileInfo(string path, string container, int? partNumber = default, int? chapterNumber = default, bool isDirectory = default) + public AudioBookFileInfo(string path, string container, int? partNumber = default, int? chapterNumber = default) { Path = path; Container = container; PartNumber = partNumber; ChapterNumber = chapterNumber; - IsDirectory = isDirectory; } /// @@ -48,12 +46,6 @@ namespace Emby.Naming.AudioBook /// The chapter number. public int? ChapterNumber { get; set; } - /// - /// Gets or sets a value indicating whether this instance is a directory. - /// - /// The type. - public bool IsDirectory { get; set; } - /// public int CompareTo(AudioBookFileInfo? other) { diff --git a/Emby.Naming/AudioBook/AudioBookListResolver.cs b/Emby.Naming/AudioBook/AudioBookListResolver.cs index 179a3bc073..0d190c172e 100644 --- a/Emby.Naming/AudioBook/AudioBookListResolver.cs +++ b/Emby.Naming/AudioBook/AudioBookListResolver.cs @@ -22,21 +22,21 @@ namespace Emby.Naming.AudioBook var audioBookResolver = new AudioBookResolver(_options); var audiobookFileInfos = files - .Select(i => audioBookResolver.Resolve(i.FullName, i.IsDirectory)) + .Select(i => audioBookResolver.Resolve(i.FullName)) .OfType() .ToList(); // Filter out all extras, otherwise they could cause stacks to not be resolved // See the unit test TestStackedWithTrailer var metadata = audiobookFileInfos - .Select(i => new FileSystemMetadata { FullName = i.Path, IsDirectory = i.IsDirectory }); + .Select(i => new FileSystemMetadata { FullName = i.Path, IsDirectory = false }); var stackResult = new StackResolver(_options) - .ResolveAudioBooks(metadata); + .ResolveAudioBooks(audiobookFileInfos); foreach (var stack in stackResult) { - var stackFiles = stack.Files.Select(i => audioBookResolver.Resolve(i, stack.IsDirectoryStack)).OfType().ToList(); + var stackFiles = stack.Files.Select(i => audioBookResolver.Resolve(i)).OfType().ToList(); stackFiles.Sort(); // TODO nullable discover if name can be empty var info = new AudioBookInfo(stack.Name ?? string.Empty) { Files = stackFiles }; diff --git a/Emby.Naming/AudioBook/AudioBookResolver.cs b/Emby.Naming/AudioBook/AudioBookResolver.cs index 56442fc4ee..c9e8c76cbc 100644 --- a/Emby.Naming/AudioBook/AudioBookResolver.cs +++ b/Emby.Naming/AudioBook/AudioBookResolver.cs @@ -17,19 +17,13 @@ namespace Emby.Naming.AudioBook _options = options; } - public AudioBookFileInfo? Resolve(string path, bool isDirectory = false) + public AudioBookFileInfo? Resolve(string path) { if (path.Length == 0) { throw new ArgumentException("String can't be empty.", nameof(path)); } - // TODO - if (isDirectory) - { - return null; - } - var extension = Path.GetExtension(path); // Check supported extensions @@ -46,8 +40,7 @@ namespace Emby.Naming.AudioBook path, container, chapterNumber: parsingResult.ChapterNumber, - partNumber: parsingResult.PartNumber, - isDirectory: isDirectory); + partNumber: parsingResult.PartNumber); } } } diff --git a/Emby.Naming/Video/StackResolver.cs b/Emby.Naming/Video/StackResolver.cs index f733cd2620..ce3152739b 100644 --- a/Emby.Naming/Video/StackResolver.cs +++ b/Emby.Naming/Video/StackResolver.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; +using Emby.Naming.AudioBook; using Emby.Naming.Common; using MediaBrowser.Model.IO; @@ -29,24 +30,16 @@ namespace Emby.Naming.Video return Resolve(files.Select(i => new FileSystemMetadata { FullName = i, IsDirectory = false })); } - public IEnumerable ResolveAudioBooks(IEnumerable files) + public IEnumerable ResolveAudioBooks(IEnumerable files) { - var groupedDirectoryFiles = files.GroupBy(file => - file.IsDirectory - ? file.FullName - : Path.GetDirectoryName(file.FullName)); + var groupedDirectoryFiles = files.GroupBy(file => Path.GetDirectoryName(file.Path)); foreach (var directory in groupedDirectoryFiles) { var stack = new FileStack { Name = Path.GetFileName(directory.Key), IsDirectoryStack = false }; foreach (var file in directory) { - if (file.IsDirectory) - { - continue; - } - - stack.Files.Add(file.FullName); + stack.Files.Add(file.Path); } yield return stack;