diff options
author | Patrick Spek <p.spek@tyil.nl> | 2023-02-08 15:39:24 +0100 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2023-02-08 15:39:24 +0100 |
commit | 4684a75dca6de001784016dfc7dcbaf78aff5492 (patch) | |
tree | 6b69caaaf5af714b7c3b4738648762a774681d61 | |
parent | 1ccb5831132440db0558619c94c96bf31d55ff20 (diff) | |
download | dotfiles-4684a75dca6de001784016dfc7dcbaf78aff5492.tar.gz dotfiles-4684a75dca6de001784016dfc7dcbaf78aff5492.tar.bz2 |
Add quick script for downloadgemist
-rwxr-xr-x | .local/bin/downloadgemist | 42 |
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) |