Get Magisk link: Fallback to Jsdelivr

Some regions can't connect to Github smoothly. Fallback to Jsdelivr.
This commit is contained in:
Howard Wu 2022-09-09 18:46:41 +08:00
parent 2d831522cf
commit 29c373b9fd

View File

@ -32,8 +32,13 @@ print(f"Generating Magisk download link: release type={magisk_ver}", flush=True)
if not magisk_ver: if not magisk_ver:
magisk_ver = "stable" magisk_ver = "stable"
if magisk_ver == "stable" or magisk_ver == "beta" or magisk_ver == "canary" or magisk_ver == "debug": if magisk_ver == "stable" or magisk_ver == "beta" or magisk_ver == "canary" or magisk_ver == "debug":
magisk_link = json.loads(requests.get( try:
f"https://github.com/topjohnwu/magisk-files/raw/master/{magisk_ver}.json").content)['magisk']['link'] magisk_link = json.loads(requests.get(
f"https://github.com/topjohnwu/magisk-files/raw/master/{magisk_ver}.json").content)['magisk']['link']
except Exception:
print("Failed to fetch from GitHub API, fallbacking to jsdelivr...")
magisk_link = json.loads(requests.get(
f"https://fastly.jsdelivr.net/gh/topjohnwu/magisk-files@master/{magisk_ver}.json").content)['magisk']['link']
print(f"download link: {magisk_link}", flush=True) print(f"download link: {magisk_link}", flush=True)
with open(download_dir/tempScript, 'a') as f: with open(download_dir/tempScript, 'a') as f: