Vikleoboy / Epub-book-Reader

9 stars 2 forks source link

Improve ePub File Reading Logic in `Book.js` #4

Closed Vikleoboy closed 4 months ago

Vikleoboy commented 4 months ago

Improve ePub File Reading Logic in Book.js

Summary

Enhance the logic in book.js to correctly read ePub book files, accounting for various folder structures beyond the current assumption of having or not having an "OPS" folder.

Current Implementation

Problem

Solution

  1. Search Logic:

    • Enhance the search logic to look for content.opf and *.ncx files within the extracted ePub book folder.
    • The search should include subfolders but be limited to a depth of two levels.
  2. Implementation Steps:

    • Modify the extraction and reading logic in Book.js to search for content.opf and *.ncx files in the following manner:
      • Start from the root of the extracted folder.
      • Search through the first level of subfolders.
      • If not found, search the second level of subfolders.
    • Once these files are found, proceed with reading the ePub content as before without changing the subsequent processing steps.

Example Structure

To clarify the search logic, consider the following structure:


books/BookName/
├── folder1/
│   ├── subfolder1/
│   │   ├── content.opf
│   │   ├── anyname.ncx
│   │   └── other files...
│   └── subfolder2/
│       └── other files...
├── folder2/
│   └── other files...
├── content.opf
├── anyname.ncx
└── other files...
Vikleoboy commented 4 months ago

Fixed it all