add script to download ruffle for flash support
This commit is contained in:
parent
295f3907e6
commit
a90430f72f
3 changed files with 47 additions and 1 deletions
42
tools/download_ruffle.py
Normal file
42
tools/download_ruffle.py
Normal file
|
|
@ -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")
|
||||
Loading…
Add table
Add a link
Reference in a new issue