mirror of
https://github.com/gotson/komga.git
synced 2026-02-03 18:27:22 -06:00
fix(epub): more lenient fixed-layout detection
This commit is contained in:
parent
58cb44583e
commit
4f94365735
@ -146,7 +146,6 @@ class BookAnalyzer(
|
||||
): Media {
|
||||
book.path.epub { epub ->
|
||||
val (resources, missingResources) = epubExtractor.getResources(epub).partition { it.fileSize != null }
|
||||
val isFixedLayout = epubExtractor.isFixedLayout(epub)
|
||||
val isKepub = epubExtractor.isKepub(epub, resources)
|
||||
|
||||
val errors = mutableListOf<String>()
|
||||
@ -180,13 +179,15 @@ class BookAnalyzer(
|
||||
|
||||
val divinaPages =
|
||||
try {
|
||||
epubExtractor.getDivinaPages(epub, isFixedLayout, analyzeDimensions)
|
||||
epubExtractor.getDivinaPages(epub, analyzeDimensions)
|
||||
} catch (e: Exception) {
|
||||
logger.error(e) { "Error while getting EPUB Divina pages" }
|
||||
errors.add("ERR_1038")
|
||||
emptyList()
|
||||
}
|
||||
|
||||
val isFixedLayout = divinaPages.isNotEmpty() || epubExtractor.isFixedLayout(epub)
|
||||
|
||||
val positions =
|
||||
try {
|
||||
epubExtractor.computePositions(epub, book.path, resources, isFixedLayout, isKepub)
|
||||
|
||||
@ -114,14 +114,8 @@ class EpubExtractor(
|
||||
|
||||
fun getDivinaPages(
|
||||
epub: EpubPackage,
|
||||
isFixedLayout: Boolean,
|
||||
analyzeDimensions: Boolean,
|
||||
): List<BookPage> {
|
||||
if (!isFixedLayout) {
|
||||
logger.info { "Epub Divina detection failed: book is not fixed layout" }
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
val pageCount =
|
||||
run {
|
||||
val spine =
|
||||
|
||||
@ -144,7 +144,6 @@ class BookAnalyzerTest(
|
||||
|
||||
assertThat(media.mediaType).isEqualTo("application/epub+zip")
|
||||
assertThat(media.status).isEqualTo(Media.Status.READY)
|
||||
assertThat(media.pages).hasSize(0)
|
||||
}
|
||||
}
|
||||
|
||||
@ -230,7 +229,7 @@ class BookAnalyzerTest(
|
||||
val file = ClassPathResource("epub/The Incomplete Theft - Ralph Burke.epub")
|
||||
val book = Book("book", file.url, LocalDateTime.now())
|
||||
|
||||
every { epubExtractor.getDivinaPages(any(), any(), any()) } throws Exception("mock exception")
|
||||
every { epubExtractor.getDivinaPages(any(), any()) } throws Exception("mock exception")
|
||||
|
||||
val media = bookAnalyzer.analyze(book, false)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user