Home - luckylittle/calibre-plugin-remove-extension GitHub Wiki

Welcome to the calibre-plugin-remove-extension wiki!

Why does it exist?

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.

Requirements

!DO NOT SHARE THESE EBOOKS IN THE PUBLIC, THE PICTURES CONTAIN UNIQUE WATERMARKS!

Instructions

  1. 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!



  1. 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/, select Copy to, choose Downloads folder on my phone. Once it is copied, i then go to Downloads, highlight the folder again, select Compress and 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 delete Offline Bookbag in the Safari app.



  1. 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.sh

b) Execute the script:

lmaly@lmaly ξ‚° ~/Downloads/1234567-9781457191435-xhtml ξ‚° ./safari2go.sh

c) You should end up with:

.
β”œβ”€β”€ 9781457191435
β”œβ”€β”€ css
β”œβ”€β”€ fonts
└── images
    └── 9781457191435
        └── assets
            └── images
cover.xhtml
metadata
safari2go.sh



  1. Run ebook-edit (Calibre binary), then go to Calibre -> File - Create new, empty book.

a) Ebook editor looks like this:

Calibre ebook editor

b) Look up author(s) and title in metadata.opf file. Enter it in the next step:



  1. Import all xhtml/html files and remove the default start.xhtml (comes with empty ebook by default) - File - Import files into book:

a) Main window:

Imported text

b) Open metadata.opf in Miscellaneous and replace everything between <manifest> and </manifest> with what is in generated spine.xml file.



  1. Use my plugin to remove the extensions of the Text files (rename back to _xhtml and _html - no extension).

Note: This step will ensure chapters are in the correct order.

a) After extension removal and sorting:

After extension removal and sorting

b) Now import images, css style(s), fonts - File - Import files into book



  1. Then go to Tools - Arrange into folders and use the same structure as the folder structure (step 3. c)):

Arrange into folders

Note: Step 7 will ensure pictures will be correctly linked in xhtml/html files & chapters and hyperlinks between xhtml/html are correct.



  1. Right-click on the cover - usually first xhtml and select Mark [____] as cover page.



  1. Press F7 to check/validate the book. Ignore warnings Invalid id and mimetype does not match its extension. All other errors could be a problem and you might need to fix it manually. Save the ebook.



  1. 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):

Calibre



[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):

Sigil

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.



Contributions

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.

!DO NOT SHARE THESE EBOOKS IN THE PUBLIC, THE PICTURES CONTAIN UNIQUE WATERMARKS!

SUPPORT THE AUTHORS IF YOU LIKE THEIR BOOKS!


⚠️ **GitHub.com Fallback** ⚠️