aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Library/Resolvers
diff options
context:
space:
mode:
authorMBR-0001 <55142207+MBR-0001@users.noreply.github.com>2026-04-18 17:14:31 +0200
committerGitHub <noreply@github.com>2026-04-18 17:14:31 +0200
commita2eff41d6617bed7a7c5518d00f227a2406a8421 (patch)
tree933386669537d5145ca6b3706728454aff27d703 /Emby.Server.Implementations/Library/Resolvers
parentd4a46bc6291560b35a9b64fb88b68019f903d0ef (diff)
parent5aa093d2997d8120ce19037642556070d27ce0bb (diff)
Merge branch 'master' into removeGlobalSubtitleConfiguration
Diffstat (limited to 'Emby.Server.Implementations/Library/Resolvers')
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs36
1 files changed, 24 insertions, 12 deletions
diff --git a/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs
index 464a548ab9..3ee1c757f2 100644
--- a/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs
@@ -5,18 +5,18 @@
using System;
using System.IO;
using System.Linq;
+using Emby.Naming.Book;
using Jellyfin.Data.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Resolvers;
-using MediaBrowser.Model.Entities;
namespace Emby.Server.Implementations.Library.Resolvers.Books
{
public class BookResolver : ItemResolver<Book>
{
- private readonly string[] _validExtensions = { ".azw", ".azw3", ".cb7", ".cbr", ".cbt", ".cbz", ".epub", ".mobi", ".pdf" };
+ private readonly string[] _validExtensions = { ".azw", ".azw3", ".cb7", ".cbr", ".cbt", ".cbz", ".epub", ".mobi", ".pdf", ".m4b", ".m4a", ".aac", ".flac", ".mp3", ".opus" };
protected override Book Resolve(ItemResolveArgs args)
{
@@ -35,17 +35,22 @@ namespace Emby.Server.Implementations.Library.Resolvers.Books
var extension = Path.GetExtension(args.Path.AsSpan());
- if (_validExtensions.Contains(extension, StringComparison.OrdinalIgnoreCase))
+ if (!_validExtensions.Contains(extension, StringComparison.OrdinalIgnoreCase))
{
- // It's a book
- return new Book
- {
- Path = args.Path,
- IsInMixedFolder = true
- };
+ return null;
}
- return null;
+ var result = BookFileNameParser.Parse(Path.GetFileNameWithoutExtension(args.Path));
+
+ return new Book
+ {
+ Path = args.Path,
+ Name = result.Name ?? string.Empty,
+ IndexNumber = result.Index,
+ ProductionYear = result.Year,
+ SeriesName = result.SeriesName ?? Path.GetFileName(Path.GetDirectoryName(args.Path)),
+ IsInMixedFolder = true,
+ };
}
private Book GetBook(ItemResolveArgs args)
@@ -59,15 +64,22 @@ namespace Emby.Server.Implementations.Library.Resolvers.Books
StringComparison.OrdinalIgnoreCase);
}).ToList();
- // Don't return a Book if there is more (or less) than one document in the directory
+ // directory is only considered a book when it contains exactly one supported file
+ // other library structures with multiple books to a directory will get picked up as individual files
if (bookFiles.Count != 1)
{
return null;
}
+ var result = BookFileNameParser.Parse(Path.GetFileName(args.Path));
+
return new Book
{
- Path = bookFiles[0].FullName
+ Path = bookFiles[0].FullName,
+ Name = result.Name ?? string.Empty,
+ IndexNumber = result.Index,
+ ProductionYear = result.Year,
+ SeriesName = result.SeriesName ?? string.Empty,
};
}
}