The Free Software Media System - Server Backend & API
Simplify AudioBookResolver since there is no option of passing directories into it (AudioResolver.cs:179) and handling directories were not implemented anyway
Stepane7a37bedfca1
diff --git a/Emby.Naming/AudioBook/AudioBookFileInfo.cs b/Emby.Naming/AudioBook/AudioBookFileInfo.csindex e5200416ee..862e396677 100644--- a/Emby.Naming/AudioBook/AudioBookFileInfo.cs+++ b/Emby.Naming/AudioBook/AudioBookFileInfo.cs@@ -14,14 +14,12 @@ namespace Emby.Naming.AudioBook/// <param name="container">File type.</param>/// <param name="partNumber">Number of part this file represents.</param>/// <param name="chapterNumber">Number of chapter this file represents.</param>- /// <param name="isDirectory">Indication if we are looking at file or directory.</param>- 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;}/// <summary>@@ -48,12 +46,6 @@ namespace Emby.Naming.AudioBook/// <value>The chapter number.</value>public int? ChapterNumber { get; set; }- /// <summary>- /// Gets or sets a value indicating whether this instance is a directory.- /// </summary>- /// <value>The type.</value>- public bool IsDirectory { get; set; }-/// <inheritdoc />public int CompareTo(AudioBookFileInfo? other){diff --git a/Emby.Naming/AudioBook/AudioBookListResolver.cs b/Emby.Naming/AudioBook/AudioBookListResolver.csindex 179a3bc073..0d190c172e 100644--- a/Emby.Naming/AudioBook/AudioBookListResolver.cs+++ b/Emby.Naming/AudioBook/AudioBookListResolver.cs@@ -22,21 +22,21 @@ namespace Emby.Naming.AudioBookvar audioBookResolver = new AudioBookResolver(_options);var audiobookFileInfos = files- .Select(i => audioBookResolver.Resolve(i.FullName, i.IsDirectory))+ .Select(i => audioBookResolver.Resolve(i.FullName)).OfType<AudioBookFileInfo>().ToList();// Filter out all extras, otherwise they could cause stacks to not be resolved// See the unit test TestStackedWithTrailervar 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<AudioBookFileInfo>().ToList();+ var stackFiles = stack.Files.Select(i => audioBookResolver.Resolve(i)).OfType<AudioBookFileInfo>().ToList();stackFiles.Sort();// TODO nullable discover if name can be emptyvar info = new AudioBookInfo(stack.Name ?? string.Empty) { Files = stackFiles };diff --git a/Emby.Naming/AudioBook/AudioBookResolver.cs b/Emby.Naming/AudioBook/AudioBookResolver.csindex 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.AudioBookpath,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.csindex 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.Videoreturn Resolve(files.Select(i => new FileSystemMetadata { FullName = i, IsDirectory = false }));}- public IEnumerable<FileStack> ResolveAudioBooks(IEnumerable<FileSystemMetadata> files)+ public IEnumerable<FileStack> ResolveAudioBooks(IEnumerable<AudioBookFileInfo> 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;