Steven Smith revised this gist . Go to revision
1 file changed, 4 insertions, 4 deletions
hbget.py
| @@ -32,8 +32,8 @@ for k in keys: | |||
| 32 | 32 | try: | |
| 33 | 33 | for line in execute(["mkdir", dl["platform"]]): | |
| 34 | 34 | pass | |
| 35 | + | url = dl["download_struct"][0]["url"]["bittorrent"] | |
| 36 | + | for line in execute(["wget", url, "-O", "{}/{}".format(dl["platform"], url.split("/")[-1].split("?")[0])]): | |
| 37 | + | print(line, end="") | |
| 35 | 38 | except: | |
| 36 | - | pass | |
| 37 | - | url = dl["download_struct"][0]["url"]["bittorrent"] | |
| 38 | - | for line in execute(["wget", url, "-O", "{}/{}".format(dl["platform"], url.split("/")[-1].split("?")[0])]): | |
| 39 | - | print(line, end="") | |
| 39 | + | pass | |
Steven Smith revised this gist . Go to revision
1 file changed, 39 insertions
hbget.py(file created)
| @@ -0,0 +1,39 @@ | |||
| 1 | + | # pypi:humblebundle has to deal with captchas. I can't be bothered. | |
| 2 | + | import requests | |
| 3 | + | import json | |
| 4 | + | import subprocess | |
| 5 | + | ||
| 6 | + | keys = [k["gamekey"] for k in json.loads(""" #paste contents of https://www.humblebundle.com/api/v1/user/order here | |
| 7 | + | """) | |
| 8 | + | ||
| 9 | + | # Open your browser's Network console while going to the above url, find the headers, paste them below | |
| 10 | + | headers = {"Cookie": "", "User-Agent": ""} | |
| 11 | + | ||
| 12 | + | # stackoverflow is the best | |
| 13 | + | def execute(cmd): | |
| 14 | + | popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True) | |
| 15 | + | for stdout_line in iter(popen.stdout.readline, ""): | |
| 16 | + | yield stdout_line | |
| 17 | + | popen.stdout.close() | |
| 18 | + | return_code = popen.wait() | |
| 19 | + | if return_code: | |
| 20 | + | raise subprocess.CalledProcessError(return_code, cmd) | |
| 21 | + | ||
| 22 | + | def get(key): | |
| 23 | + | return requests.get("https://www.humblebundle.com/api/v1/order/{}".format(key), headers=headers).json() | |
| 24 | + | ||
| 25 | + | for k in keys: | |
| 26 | + | resp = get(k) | |
| 27 | + | if not resp["subproducts"]: | |
| 28 | + | continue | |
| 29 | + | for sp in resp["subproducts"]: | |
| 30 | + | for dl in sp["downloads"]: | |
| 31 | + | if dl.get("download_struct", []) and dl["download_struct"][0].get("url", {}).get("bittorrent", ""): | |
| 32 | + | try: | |
| 33 | + | for line in execute(["mkdir", dl["platform"]]): | |
| 34 | + | pass | |
| 35 | + | except: | |
| 36 | + | pass | |
| 37 | + | url = dl["download_struct"][0]["url"]["bittorrent"] | |
| 38 | + | for line in execute(["wget", url, "-O", "{}/{}".format(dl["platform"], url.split("/")[-1].split("?")[0])]): | |
| 39 | + | print(line, end="") | |