Skip to content

Instantly share code, notes, and snippets.

@fernandojsg
Created October 30, 2021 08:32
Show Gist options
  • Save fernandojsg/c8646b917e10e60f2bae31600eb1411d to your computer and use it in GitHub Desktop.
Save fernandojsg/c8646b917e10e60f2bae31600eb1411d to your computer and use it in GitHub Desktop.
Libro inglés
import img2pdf
import os
dirname = "."
imgs = []
for i in range(143):
path = os.path.join(dirname, str(i + 1) + ".jpg")
if os.path.isdir(path):
continue
imgs.append(path)
with open("output.pdf","wb") as f:
f.write(img2pdf.convert(imgs))
async function download() {
let i = 1
const numImages = 143
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
let int = setInterval( async function() {
if ( i > numImages ) {
clearInterval( int );
return;
}
document.getElementById(`thumbnail-${i}`).click()
await sleep(1000)
const img = document.querySelector(`li[data-page-number="${i}"] > .fullsize-image`)
let a = document.createElement('a');
a.href = img.src;
a.download = `${i}.jpg`;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
i++;
}, 500)
}
download()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment