aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/downloadgemist
blob: d690ba8ee0ce62585c4c6f7350962cea20a981f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3

import argparse
import requests
import sys

# Handle arguments
argparser = argparse.ArgumentParser(
    description = "Command line utility to interact with downloadgemist.nl",
)
argparser.add_argument("url")

args = argparser.parse_args()

# Make the actual HTTP request
form = requests.post(
    "https://www.downloadgemist.nl/core/hyperbridge.php",
    data={
        "mode": "initiate",
        "link": args.url,
        "options": '{"size":"large","download_tt888":true}',
    },
)

# Make sure the response is json
if form.headers.get("Content-Type").lower() != "application/json":
    print("oh no")
    sys.exit(1)

json = form.json()

print(form.json())

# Handle any errors
if json["status"] == 1:
    print(form.json()["error"])
    sys.exit(form.json()["status"])

# Write the downloaded file
video = requests.get(json["file"])

open(json["filename"], "wb").write(video.content)