From a90430f72f3a852c7b7f0fb3906e8c6ecd61c79e Mon Sep 17 00:00:00 2001 From: notfire Date: Fri, 27 Jun 2025 17:53:37 -0400 Subject: [PATCH] add script to download ruffle for flash support --- .gitignore | 4 +++- README.md | 2 ++ tools/download_ruffle.py | 42 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 tools/download_ruffle.py diff --git a/.gitignore b/.gitignore index a0be5c16..5ad1b015 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,6 @@ selenium-debug.log config/local.json config/local.*.json docs/site/ -.vscode/ \ No newline at end of file +.vscode/ +tools/.venv/ +static/ruffle/ diff --git a/README.md b/README.md index a44def70..4a5b7be9 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,8 @@ - script to get new emojis is included for future unicode versions - add toggle for showing post edit notifications - add support for accepted follow request notifications +- add a script to download ruffle for flash support (requires python3 and requests library) + - download by entering `tools/` and running `python3 download_ruffle.py` --- diff --git a/tools/download_ruffle.py b/tools/download_ruffle.py new file mode 100644 index 00000000..7c4905a0 --- /dev/null +++ b/tools/download_ruffle.py @@ -0,0 +1,42 @@ +import requests, json, zipfile, os, glob + +if os.path.isdir("../static/ruffle/"): + print("Flash is already downloaded, clearing old directory and updating...") + rm = glob.glob("../static/ruffle/*") + for x in rm: + os.remove(x) +else: + print("Flash is not downloaded yet, creating directory...") + os.mkdir("../static/ruffle/") + +releases = requests.get("https://api.github.com/repos/ruffle-rs/ruffle/releases?per_page=1") +releasesJsonified = json.loads(releases.text) + +for asset in releasesJsonified[0]["assets"]: + if "web-selfhosted" in asset["browser_download_url"]: + newFlashFiles = requests.get(asset["browser_download_url"]) + flashDumped = open("flash.zip", "wb+") + flashDumped.write(newFlashFiles.content) + + flashZip = zipfile.ZipFile("flash.zip", "r") + flashZip.extractall("../static/ruffle/") + + rmglob = glob.glob("../static/ruffle/*.map") + rm = ["../static/ruffle/README.md", + "../static/ruffle/LICENSE_MIT", + "../static/ruffle/LICENSE_APACHE", + "../static/ruffle/package.json"] + for item in rmglob: + rm.append(item) + + for item in rm: + os.remove(item) + + flashZip.close() + + os.remove("flash.zip") + + print("Flash was successfully downloaded and extracted") + exit() + +print("Flash not found, download it manually at https://github.com/ruffle-rs/ruffle/releases")