aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Library/Resolvers
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2026-02-14 12:07:30 +0100
committerGitHub <noreply@github.com>2026-02-14 12:07:30 +0100
commit29582ed461b693368ec56567c2e40cfa20ef4bf5 (patch)
tree04721b833e8e6108c2e13c4f0ea9f4dc7b2ae946 /Emby.Server.Implementations/Library/Resolvers
parentca6d499680f9fbb369844a11eb0e0213b66bb00b (diff)
parent3b6985986709473c69ba785460c702c6bbe3771d (diff)
Merge branch 'master' into issue15137
Diffstat (limited to 'Emby.Server.Implementations/Library/Resolvers')
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs34
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs11
2 files changed, 30 insertions, 15 deletions
diff --git a/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs
index 464a548ab..1e885aad6 100644
--- a/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs
@@ -5,12 +5,12 @@
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
{
@@ -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,
};
}
}
diff --git a/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
index 333c8c34b..98e8f5350 100644
--- a/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
@@ -369,13 +369,16 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
// We need to only look at the name of this actual item (not parents)
var justName = item.IsInMixedFolder ? Path.GetFileName(item.Path.AsSpan()) : Path.GetFileName(item.ContainingFolderPath.AsSpan());
- if (!justName.IsEmpty)
+ var tmdbid = justName.GetAttributeValue("tmdbid");
+
+ // If not in a mixed folder and ID not found in folder path, check filename
+ if (string.IsNullOrEmpty(tmdbid) && !item.IsInMixedFolder)
{
- // Check for TMDb id
- var tmdbid = justName.GetAttributeValue("tmdbid");
- item.TrySetProviderId(MetadataProvider.Tmdb, tmdbid);
+ tmdbid = Path.GetFileName(item.Path.AsSpan()).GetAttributeValue("tmdbid");
}
+ item.TrySetProviderId(MetadataProvider.Tmdb, tmdbid);
+
if (!string.IsNullOrEmpty(item.Path))
{
// Check for IMDb id - we use full media path, as we can assume that this will match in any use case (whether id in parent dir or in file name)