feat: update the package a bit, conform to pep8
This commit is contained in:
parent
867786099a
commit
fcf24cd5cd
6 changed files with 80 additions and 106 deletions
36
hb_downloader.py
Executable file
36
hb_downloader.py
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
#!/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")
|
||||
Loading…
Add table
Add a link
Reference in a new issue