diff options
| author | Stepan <ste.martinek+git@gmail.com> | 2020-11-01 17:10:48 +0100 |
|---|---|---|
| committer | Stepan <ste.martinek+git@gmail.com> | 2020-11-01 17:10:48 +0100 |
| commit | f39775dc3a813609454655c31dd5c6a1413cc890 (patch) | |
| tree | 29a7415e8be89341e8b7c9a0a77e521f6ba44432 /Emby.Naming/AudioBook | |
| parent | e7a37bedfca159ab6a305833395aead07ccd872f (diff) | |
Written test to finish coverage for AudioBookListResolver & AudioBookResolver and corrected some logical erros / unhandled exception
Diffstat (limited to 'Emby.Naming/AudioBook')
| -rw-r--r-- | Emby.Naming/AudioBook/AudioBookListResolver.cs | 20 | ||||
| -rw-r--r-- | Emby.Naming/AudioBook/AudioBookResolver.cs | 3 |
2 files changed, 14 insertions, 9 deletions
diff --git a/Emby.Naming/AudioBook/AudioBookListResolver.cs b/Emby.Naming/AudioBook/AudioBookListResolver.cs index 0d190c172..795065a6c 100644 --- a/Emby.Naming/AudioBook/AudioBookListResolver.cs +++ b/Emby.Naming/AudioBook/AudioBookListResolver.cs @@ -1,6 +1,8 @@ #pragma warning disable CS1591 +using System; using System.Collections.Generic; +using System.IO; using System.Linq; using Emby.Naming.Common; using Emby.Naming.Video; @@ -21,25 +23,27 @@ namespace Emby.Naming.AudioBook { var audioBookResolver = new AudioBookResolver(_options); + // File with empty fullname will be sorted out here var audiobookFileInfos = files .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 TestStackedWithTrailer - var metadata = audiobookFileInfos - .Select(i => new FileSystemMetadata { FullName = i.Path, IsDirectory = false }); - var stackResult = new StackResolver(_options) .ResolveAudioBooks(audiobookFileInfos); foreach (var stack in stackResult) { - var stackFiles = stack.Files.Select(i => audioBookResolver.Resolve(i)).OfType<AudioBookFileInfo>().ToList(); + var stackFiles = stack.Files + .Select(i => audioBookResolver.Resolve(i)) + .OfType<AudioBookFileInfo>() + .ToList(); + stackFiles.Sort(); - // TODO nullable discover if name can be empty - var info = new AudioBookInfo(stack.Name ?? string.Empty) { Files = stackFiles }; + + // stack.Name can be empty when we have file without folder, but always have some files + var name = string.IsNullOrEmpty(stack.Name) ? stack.Files[0] : stack.Name; + var info = new AudioBookInfo(name) { Files = stackFiles }; yield return info; } diff --git a/Emby.Naming/AudioBook/AudioBookResolver.cs b/Emby.Naming/AudioBook/AudioBookResolver.cs index c9e8c76cb..542d6fee5 100644 --- a/Emby.Naming/AudioBook/AudioBookResolver.cs +++ b/Emby.Naming/AudioBook/AudioBookResolver.cs @@ -21,7 +21,8 @@ namespace Emby.Naming.AudioBook { if (path.Length == 0) { - throw new ArgumentException("String can't be empty.", nameof(path)); + // Return null to indicate this path will not be used, instead of stopping whole process with exception + return null; } var extension = Path.GetExtension(path); |
