36 lines
1.2 KiB
Python
Executable file
36 lines
1.2 KiB
Python
Executable file
#!/bin/env python
|
|
"""Simple python program for getting all links from humble bundle book bundles"""
|
|
|
|
# pylint: disable=C0103
|
|
|
|
import json
|
|
|
|
import requests
|
|
|
|
cookie = input("Cookie String: ")
|
|
key = input("Order Key: ")
|
|
|
|
response = requests.get(
|
|
f"https://www.humblebundle.com/api/v1/order/{key}",
|
|
headers={"Cookie": cookie},
|
|
timeout=10,
|
|
)
|
|
|
|
books = json.loads(response.text)
|
|
|
|
with open("files.txt", "w", encoding="UTF-8") as file:
|
|
for book in books["subproducts"]:
|
|
name = book["human_name"]
|
|
publisher = book["payee"]["human_name"]
|
|
if len(book["downloads"][0]["download_struct"]) > 1:
|
|
for download in book["downloads"][0]["download_struct"]:
|
|
link = download["url"]["web"]
|
|
file_name = f"{name} - {publisher}.{download['name'].lower()}"
|
|
file.write(f"{link}\n")
|
|
file.write(f" out={file_name.replace('/', ' ')}\n")
|
|
else:
|
|
download = book["downloads"][0]["download_struct"][0]
|
|
link: str = download["url"]["web"]
|
|
file_name: str = f"{name} - {publisher}.{download['name'].lower()}"
|
|
file.write(f"{link}\n")
|
|
file.write(f" out={file_name.replace('/', ' ')}\n")
|