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
We use a custom API in book.js to read the content of ePub book files such as the cover page.
The current logic extracts the ePub file as a zip and searches for an "OPS" folder.
If an "OPS" folder is present, it is considered the base folder.
If no "OPS" folder is found, the root directory is considered the base folder.
Problem
The current logic assumes only two structures: having an "OPS" folder or not.
There can be other folder structures in ePub files.
We need to improve the logic to search for content.opf and *.ncx files within the book folder, even if these files are located in subfolders.
Solution
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.
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...
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
book.js
to read the content of ePub book files such as the cover page.Problem
content.opf
and*.ncx
files within the book folder, even if these files are located in subfolders.Solution
Search Logic:
content.opf
and*.ncx
files within the extracted ePub book folder.Implementation Steps:
Book.js
to search forcontent.opf
and*.ncx
files in the following manner:Example Structure
To clarify the search logic, consider the following structure: