Home - luckylittle/calibre-plugin-remove-extension GitHub Wiki
I was looking for ways how to extract ebooks from Safari books online so i can read them on other devices. Please note this is the OLD portal and not the NEW O'Reilly Safari!
During my research, i found that there is a way how to export the files on your phone and then turn it into retail ebooks with little effort. This page explains step-by-step how to do this and how this plugin fits in the whole picture.
- Safari books online account/subscription
- Rooted Android phone
- Safari To Go app v1.9.1
- ES File Explorer File Manager v1.1.2
-
safari2go.sh - you'll need to have
xmllint,sed,wget,find - Calibre v3.21
- My plugin calibre-plugin-remove-extension v0.0.2 (To install go to PreferencesβββAdvancedβββPluginsβββLoad plugin from file)
- Sigil-Ebook v0.9.9
- Bash
- First of all, in your Safari android app, download/add the desired book to your
Offline Bookbag. Note: You can only have three at a time!
- Use ES File Explorer to copy folder
/data/media/0/Android/data/com.safaribooksonline/files/zips/<USERID?>-<EBOOKID>-xhtml/(that is where the offline book is stored) from your Android phone to a different folder and then to your computer. There are many ways how to do it: i typically highlight the bookbag folder inside../zips/, selectCopy to, chooseDownloadsfolder on my phone. Once it is copied, i then go toDownloads, highlight the folder again, selectCompressand zip it up. I transfer this zip file to my network share within the same app. Nice and easy, i don't even need USB cable. I then deleteOffline Bookbagin the Safari app.
- Use this bash script to prepare files for import to Calibre. Copy and run this script inside the
<USERID?>-<EBOOKID>-xhtml/folder:
a) The folder structure looks like this at the beginning:
.
βββ 9781457191435
βββ images
βββ 9781457191435
βββ assets
βββ images
metadata
publisher-style.css
safari2go.shb) Execute the script:
lmaly@lmaly ξ° ~/Downloads/1234567-9781457191435-xhtml ξ° ./safari2go.shc) You should end up with:
.
βββ 9781457191435
βββ css
βββ fonts
βββ images
βββ 9781457191435
βββ assets
βββ images
cover.xhtml
metadata
safari2go.sh- Run
ebook-edit(Calibre binary), then go to Calibre -> File - Create new, empty book.
a) Ebook editor looks like this:
b) Look up author(s) and title in metadata.opf file. Enter it in the next step:
- Import all
xhtml/htmlfiles and remove the defaultstart.xhtml(comes with empty ebook by default) - File - Import files into book:
a) Main window:
b) Open metadata.opf in Miscellaneous and replace everything between <manifest> and </manifest> with what is in generated spine.xml file.
- Use my plugin to remove the extensions of the Text files (rename back to
_xhtmland_html- no extension).
Note: This step will ensure chapters are in the correct order.
a) After extension removal and sorting:
b) Now import images, css style(s), fonts - File - Import files into book
- Then go to Tools - Arrange into folders and use the same structure as the folder structure (step
3. c)):
Note: Step 7 will ensure pictures will be correctly linked in xhtml/html files & chapters and hyperlinks between xhtml/html are correct.
- Right-click on the cover - usually first
xhtmland selectMark [____] as cover page.
- Press
F7to check/validate the book. Ignore warningsInvalid idandmimetype does not match its extension. All other errors could be a problem and you might need to fix it manually. Save the ebook.
- Go to Calibre, import the file and make sure the ebook has a visible cover (if it does not, you did something wrong). Open the book and visually check if everything is correct - are the links working? Can you see the images? Is the TOC working? Eventually you can also download missing metadata (
Ctrl+D):
[Optional] 11. You can now Right-click - Convert books - Convert individually and turn your epub to mobi and pdf. Once again validate if the other format(s) are correctly converted. Are the links working? Can you see the images? Is the TOC working?
[Optional] 12. Open the epub in Sigil, press F7 to validate everything, save the new epub to make it compatible with Google Play Books (which sometimes have problems with ebooks from Calibre):
Note: I don't know what Sigil does differently (apart from different structure - e.g. Text/, Styles/, Images/, Fonts/, Audio/, Video/, Misc/, toc.ncx, content.opf), but it works better with Google Play Books.
See the Case study / comparison on this Wiki to understand what are the differences between retail Packt Publishing eBook and Safari eBook that was exported using this method. More improvements to safari2go.sh could be done in the future, as a result of this comparison.





