Skip to content

Commit

Permalink
🛠️ Fix some books cannot parse in EPUB
Browse files Browse the repository at this point in the history
* Fixed the scenario when the book has "volume.opf" instead of "content.opf"
  • Loading branch information
Acclorite committed Nov 16, 2024
1 parent a3a18e7 commit 0077241
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class EpubFileParser @Inject constructor() : FileParser {
withContext(Dispatchers.IO) {
ZipFile(file).use { zip ->
val opfEntry = zip.entries().asSequence().find { entry ->
entry.name.endsWith("content.opf")
entry.name.endsWith(".opf", ignoreCase = true)
} ?: return@withContext

val opfContent = zip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ class EpubTextParser @Inject constructor(
entry.name.endsWith("toc.ncx", ignoreCase = true)
}
val opfEntry = zip.entries().toList().find { entry ->
entry.name.endsWith("content.opf", ignoreCase = true)
entry.name.endsWith(".opf", ignoreCase = true)
}

val chapterEntries = zip.getChapterEntries(opfEntry)
val chapterTitleEntries = zip.getChapterTitleMapFromToc(tocEntry)

Log.i(EPUB_TAG, "TOC Entry: ${tocEntry?.name ?: "no toc.ncx"}")
Log.i(EPUB_TAG, "OPF Entry: ${opfEntry?.name ?: "no content.opf"}")
Log.i(EPUB_TAG, "OPF Entry: ${opfEntry?.name ?: "no .opf entry"}")
Log.i(EPUB_TAG, "Chapter entries, size: ${chapterEntries.size}")
Log.i(EPUB_TAG, "Title entries, size: ${chapterTitleEntries?.size}")

Expand Down

0 comments on commit 0077241

Please sign in to comment.