Improve cover image extraction from epub files

This commit is contained in:
Tom Tomonari 2024-04-14 23:27:31 +08:00 committed by Cody Robibero
parent 3bfc2e6e94
commit 48ebbea268
2 changed files with 4 additions and 4 deletions

View File

@ -102,7 +102,7 @@ namespace Jellyfin.Plugin.Bookshelf.Providers.Epub
}
var opfRootDirectory = Path.GetDirectoryName(opfFilePath);
if (string.IsNullOrEmpty(opfRootDirectory))
if (opfRootDirectory == null)
{
return new DynamicImageResponse { HasImage = false };
}

View File

@ -55,13 +55,13 @@ namespace Jellyfin.Plugin.Bookshelf.Providers
return coverImage;
}
var coverId = ReadEpubCoverInto(opfRootDirectory, "//opf:item[@id='cover']");
var coverId = ReadEpubCoverInto(opfRootDirectory, "//opf:item[@id='cover' and @media-type='image/*']");
if (coverId is not null)
{
return coverId;
}
var coverImageId = ReadEpubCoverInto(opfRootDirectory, "//opf:item[@id='cover-image']");
var coverImageId = ReadEpubCoverInto(opfRootDirectory, "//opf:item[@id='*cover-image']");
if (coverImageId is not null)
{
return coverImageId;
@ -239,7 +239,7 @@ namespace Jellyfin.Plugin.Bookshelf.Providers
{
try
{
commitResult(Convert.ToInt32(resultValue, CultureInfo.InvariantCulture));
commitResult(Convert.ToInt32(Convert.ToDouble(resultValue, CultureInfo.InvariantCulture)));
}
catch (Exception e)
{