wiki:download_all_pdfs_humble_bundle
                Differences
This shows you the differences between two versions of the page.
| wiki:download_all_pdfs_humble_bundle [2021/03/31 10:58] – created antisa | wiki:download_all_pdfs_humble_bundle [2021/03/31 11:02] (current) – antisa | ||
|---|---|---|---|
| Line 17: | Line 17: | ||
| wget --content-disposition -i wgetfiles | wget --content-disposition -i wgetfiles | ||
| + | ===== Alternative python script ===== | ||
| + | <file python get_humble_order.py> | ||
| + | # | ||
| + | # -*- 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(" | ||
| + | sys.exit() | ||
| + | |||
| + | # reporthook taken from https:// | ||
| + | def reporthook(count, | ||
| + | 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), | ||
| + | sys.stdout.write(" | ||
| + | (percent, progress_size / (1024 * 1024), speed, duration)) | ||
| + | sys.stdout.flush() | ||
| + | |||
| + | url = " | ||
| + | print(url) | ||
| + | response = urllib.urlopen(url) | ||
| + | data = json.loads(response.read()) | ||
| + | |||
| + | products_count = len(data[" | ||
| + | i = 0 | ||
| + | while i < products_count: | ||
| + | try: | ||
| + | human_name = data[" | ||
| + | download_options = len(data[" | ||
| + | except: | ||
| + | print(" | ||
| + | j += 1 | ||
| + | i += 1 | ||
| + | continue | ||
| + | j = 0 | ||
| + | while j < download_options: | ||
| + | dl_type = (data[" | ||
| + | try: | ||
| + | arg_iter = 2 | ||
| + | while arg_iter < len(args[0]): | ||
| + | if ((args[0][arg_iter]).lower() in dl_type): | ||
| + | dl_url = data[" | ||
| + | dl_file = urllib.URLopener() | ||
| + | print(" | ||
| + | dl_file.retrieve(dl_url, | ||
| + | arg_iter += 1 | ||
| + | except Exception as e: | ||
| + | print(e) | ||
| + | break | ||
| + | j += 1 | ||
| + | i += 1 | ||
| + | |||
| + | print(" | ||
| + | </ | ||
| ====== Tested on ====== | ====== Tested on ====== | ||
wiki/download_all_pdfs_humble_bundle.1617188285.txt.gz · Last modified:  by antisa
                
                