Skip to content

Instantly share code, notes, and snippets.

@CPlusPatch
Created September 8, 2022 04:16
Show Gist options
  • Save CPlusPatch/3a59af2d722ea06abb2b5032b89b33f4 to your computer and use it in GitHub Desktop.
Save CPlusPatch/3a59af2d722ea06abb2b5032b89b33f4 to your computer and use it in GitHub Desktop.
Instructions to batch download a Hachette book from Educadhoc
  1. Find the book IBAN

In my case, it is 9782017092605

  1. Go to the Educadhoc demo for this IBAN

(replace with the book IBAN) https://demo.educadhoc.fr/reader/textbook//fxl/Page_1?feature=freemium

  1. Execute these commands
  curl "https://exobank.hachette-livre.fr/contents/final/<IBAN>-fxl/OEBPS/Page_[1-<NB_PAGES>].html?interface=postMessage" -o "page_#1.html"   
  curl "https://exobank.hachette-livre.fr/contents/final/<IBAN>-fxl/OEBPS/images/img-[1-<NB_PAGES>]-1.jpg" -o "images/img-#1-1.jpg"  
  curl "https://exobank.hachette-livre.fr/contents/final/<IBAN>-fxl/OEBPS/fonts/font-[0-<NB_FONTS>].otf" -o "fonts/font-#1.otf"  

Execute this script to turn the pages into PDFs

for i in $(seq 1 <NB_PAGES>)
do
  sudo wkhtmltopdf --disable-javascript --disable-external-links --enable-local-file-access --zoom 1.7 -L 0 -R 0  "page_$i.html" "pages/page_$i.pdf"
done

Fuse all the pages:

pdftk page_*.pdf cat output full_book.pdf

And compress the resulting file:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress -dNOPAUSE -dQUIET -dBATCH -sOutputFile=compressed_book.pdf full_book.pdf      
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment