Skip to content

Instantly share code, notes, and snippets.

@lukaszx0
Last active August 3, 2017 04:32
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save lukaszx0/0044aeb9ce86a7859a235093986ef885 to your computer and use it in GitHub Desktop.
Save lukaszx0/0044aeb9ce86a7859a235093986ef885 to your computer and use it in GitHub Desktop.
# Usage:
# 1) Ctr+S downloads page to ~/Desktop/books.html
# 2) Run script
# 3) Find your books in /tmp/humble_books
# 4) Read them
# 5) Profit
cat ~/Desktop/books.html |
grep "https://dl.humble.com" |
sed -n -E 's/.data-web\=\"(https://dl.humble.com/([.]+).([a-z]+)?["]+)./\1 \2 \3/p' |
sed 's/&/&/g' > /tmp/humble_books_list && cat /tmp/humble_books_list |
awk '{print $2}' |
uniq |
xargs -I"{}" mkdir -p /tmp/humble_books/{} && cat /tmp/humble_books_list |
awk '{print "curl -o /tmp/humble_books/" $2 "/" $2 "." $3 " \"" $1 "\"" }' |
while read line; do eval $line; done
@davoclavo
Copy link

Thanks! I had to make some minor adjustments to get it working on my bash.

cat ~/Desktop/books.html | grep "https://dl.humble.com" | sed -n -E 's_.+data-web\=\"(https://dl.humble.com/([^.]+)\.([^?]+)[^"]+).+_\1 \2 \3_p' | sed 's/&/\&/g' > /tmp/humble_books_list && cat /tmp/humble_books_list | awk '{print $2}' | uniq | xargs -I"{}" mkdir -p /tmp/humble_books/{} && cat /tmp/humble_books_list | awk '{print "curl -o /tmp/humble_books/" $2 "/" $2 "." $3 " \"" $1 "\"" }' | while read line; do eval $line; done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment