hbget.py
· 1.4 KiB · Python
Raw
# pypi:humblebundle has to deal with captchas. I can't be bothered.
import requests
import json
import subprocess
keys = [k["gamekey"] for k in json.loads(""" #paste contents of https://www.humblebundle.com/api/v1/user/order here
""")
# Open your browser's Network console while going to the above url, find the headers, paste them below
headers = {"Cookie": "", "User-Agent": ""}
# stackoverflow is the best
def execute(cmd):
popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True)
for stdout_line in iter(popen.stdout.readline, ""):
yield stdout_line
popen.stdout.close()
return_code = popen.wait()
if return_code:
raise subprocess.CalledProcessError(return_code, cmd)
def get(key):
return requests.get("https://www.humblebundle.com/api/v1/order/{}".format(key), headers=headers).json()
for k in keys:
resp = get(k)
if not resp["subproducts"]:
continue
for sp in resp["subproducts"]:
for dl in sp["downloads"]:
if dl.get("download_struct", []) and dl["download_struct"][0].get("url", {}).get("bittorrent", ""):
try:
for line in execute(["mkdir", dl["platform"]]):
pass
url = dl["download_struct"][0]["url"]["bittorrent"]
for line in execute(["wget", url, "-O", "{}/{}".format(dl["platform"], url.split("/")[-1].split("?")[0])]):
print(line, end="")
except:
pass
| 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 | 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="") |
| 38 | except: |
| 39 | pass |