Skip to content

Instantly share code, notes, and snippets.

@mtfurlan
Last active March 2, 2020 17:39
Show Gist options
  • Save mtfurlan/3ec82f7a341d0ffd1e062da4e5da403a to your computer and use it in GitHub Desktop.
Save mtfurlan/3ec82f7a341d0ffd1e062da4e5da403a to your computer and use it in GitHub Desktop.
Download humble bundle books

humble bundle book downloader

I want to download books so they are easy to import to calbire. This means one dir per book. This is the first way I thoght of to do this after I learned their HTML is malformed and therefore not easily parsable.

instructions

  1. Run the js in your browser console
  2. Copy the output to a file
  3. bash file
  4. ???
  5. profit
let rows = Array.from(document.getElementsByClassName('row'));
let outStr = '#!/bin/bash\nset -euo pipefail\ncd $(dirname "$0")\n\n'
rows.forEach((row) => {
let title = row.getAttribute("data-human-name");
//outStr += `echo '${title}'\n`; //this doesn't escape properly
Array.from(row.getElementsByTagName('a')).filter((element) => {
return element.href.includes('dl.humble.com');
}).forEach((link) => {
let filename = link.href.split("?")[0].split('humble.com/')[1];
let dir = filename.split('.')[0];
outStr += `mkdir -p '${dir}' && wget -O ${dir}/${filename} '${link.href}'\n`;
})
})
outStr += "\n\n";
console.log(outStr);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment