aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x.local/bin/downloadgemist42
1 files changed, 42 insertions, 0 deletions
diff --git a/.local/bin/downloadgemist b/.local/bin/downloadgemist
new file mode 100755
index 0000000..d690ba8
--- /dev/null
+++ b/.local/bin/downloadgemist
@@ -0,0 +1,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)