From 4684a75dca6de001784016dfc7dcbaf78aff5492 Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Wed, 8 Feb 2023 15:39:24 +0100 Subject: Add quick script for downloadgemist --- .local/bin/downloadgemist | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 .local/bin/downloadgemist 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) -- cgit v1.1