@@ -47,20 +47,32 @@ def __call__(self, r):
47
47
"download" if sys .argv [2 ] == "" else Path (sys .argv [2 ])
48
48
tempScript = sys .argv [3 ]
49
49
download_files = {}
50
+ cdn_hosts = ["cdn.jsdelivr.net" , "fastly.jsdelivr.net" , "testingcf.jsdelivr.net" , "gcore.jsdelivr.net" ]
50
51
print (
51
52
f"Generating Magisk download link: release type={ magisk_ver } " , flush = True )
53
+ magisk_link = None
52
54
if not magisk_ver :
53
55
magisk_ver = "stable"
54
56
if magisk_ver == "stable" or magisk_ver == "beta" or magisk_ver == "canary" or magisk_ver == "debug" :
55
57
try :
56
58
magisk_link = json .loads (requests .get (
57
- f"https://github.com/topjohnwu/ magisk-files/raw/master /{ magisk_ver } .json" ).content )['magisk' ]['link' ]
59
+ f"https://topjohnwu. github.io/ magisk-files/{ magisk_ver } .json" ).content )['magisk' ]['link' ]
58
60
download_files [f"magisk-{ magisk_ver } .zip" ] = magisk_link
59
61
except Exception :
60
62
print ("Failed to fetch from GitHub API, fallbacking to jsdelivr..." )
61
- magisk_link = json .loads (requests .get (
62
- f"https://fastly.jsdelivr.net/gh/topjohnwu/magisk-files@master/{ magisk_ver } .json" ).content )['magisk' ]['link' ]
63
- download_files [f"magisk-{ magisk_ver } .zip" ] = magisk_link
63
+ for host in cdn_hosts :
64
+ try :
65
+ magisk_link = json .loads (requests .get (
66
+ f"https://{ host } /gh/topjohnwu/magisk-files@master/{ magisk_ver } .json" ).content )['magisk' ]['link' ]
67
+ download_files [f"magisk-{ magisk_ver } .zip" ] = magisk_link
68
+ break
69
+ except Exception :
70
+ print (f"Failed to fetch from { host } , trying next..." , flush = True )
71
+ pass
72
+ finally :
73
+ if magisk_link is None :
74
+ print ("Failed to fetch Magisk download link" , flush = True )
75
+ exit (1 )
64
76
res = requests .get (
65
77
f"https://api.github.com/repos/LSPosed/WSA-Addon/releases/latest" , auth = github_auth )
66
78
json_data = json .loads (res .content )
0 commit comments