User Tools

Site Tools


wiki:download_all_pdfs_humble_bundle

Download all pdfs from Humble Bundle

Open website inspector (Ctrl+Shift+i), then in console paste this.

`cmds = ""; for (a of document.getElementsByTagName("a")) { if (a.href.startsWith("https://dl.humble.com")) cmds += "wget --content-disposition \"" + a.href + "\"\n"; }; console.log(cmds);`
sed -i 's/wget --content-disposition//g' wgetfiles
sed -i '/pdf/!d' wgetfiles
sed -i 's/\"//g' wgetfiles

Download just PDFs

wget --content-disposition -i wgetfiles

Alternative python script

get_humble_order.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
 
import sys
import urllib, json, time
 
'''
    Download your order from Humble Bundle.
 
    * Usage:
 
    python get_humble_order.py [your_order_key] [desired formats seperated by a space]
 
    * Example:
 
    python get_humble_order.py k____________XvN epub pdf 
 
    * Limitations:
 
        - be aware of the directory you're using; usually the files will be downloaded to where you call the script from
        - all existing files with the same name will be overwritten 
 
'''
 
args = []
args.append(sys.argv)
 
if len(args[0]) < 3:
    print("Too few arguments.")
    sys.exit()
 
# reporthook taken from https://blog.shichao.io/2012/10/04/progress_speed_indicator_for_urlretrieve_in_python.html
def reporthook(count, block_size, total_size):
    global start_time
    if count == 0:
        start_time = time.time()
        return
    duration = time.time() - start_time
    progress_size = int(count * block_size)
    speed = int(progress_size / (1024 * duration))
    percent = min(int(count * block_size * 100 / total_size), 100)
    sys.stdout.write("\r...%d%%, %d MB, %d KB/s, %d seconds passed" %
                    (percent, progress_size / (1024 * 1024), speed, duration))
    sys.stdout.flush()
 
url = "https://hr-humblebundle.appspot.com/api/v1/order/{0}".format(args[0][1])
print(url)
response = urllib.urlopen(url)
data = json.loads(response.read())
 
products_count = len(data["subproducts"])
i = 0
while i < products_count:
    try:
        human_name = data["subproducts"][i]["human_name"]
        download_options = len(data["subproducts"][i]["downloads"][0]["download_struct"])
    except:
        print("\n Non-file item. Skipping. \n")
        j += 1
        i += 1
        continue    
    j = 0
    while j < download_options:
        dl_type = (data["subproducts"][i]["downloads"][0]["download_struct"][j]["name"]).lower()
        try:
            arg_iter = 2
            while arg_iter < len(args[0]):
                if ((args[0][arg_iter]).lower() in dl_type):
                    dl_url = data["subproducts"][i]["downloads"][0]["download_struct"][j]["url"]["web"]
                    dl_file = urllib.URLopener()
                    print("\n" + human_name + " ({0})".format(dl_type.upper()))
                    dl_file.retrieve(dl_url, "{0}.{1}".format(human_name,dl_type), reporthook)
                arg_iter += 1
        except Exception as e:
            print(e)
            break        
        j += 1
    i += 1
 
print("\n")

Tested on

See also

References

wiki/download_all_pdfs_humble_bundle.txt · Last modified: 2021/03/31 13:02 by antisa

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki