mirror of
https://github.com/MeoProject/lx-music-api-server.git
synced 2025-05-23 19:17:41 +08:00
feat: 优化脚本获取
This commit is contained in:
parent
c51162d072
commit
12f9e90045
@ -18,16 +18,39 @@ import re
|
|||||||
|
|
||||||
logger = log('lx_script')
|
logger = log('lx_script')
|
||||||
|
|
||||||
|
jsd_mirror_list = [
|
||||||
|
'https://cdn.jsdelivr.net',
|
||||||
|
'https://gcore.jsdelivr.net',
|
||||||
|
'https://fastly.jsdelivr.net',
|
||||||
|
'https://jsd.cdn.zzko.cn',
|
||||||
|
'https://jsdelivr.b-cdn.net',
|
||||||
|
]
|
||||||
|
githun_raw_mirror_list = [
|
||||||
|
'https://raw.githubusercontent.com',
|
||||||
|
'https://mirror.ghproxy.com/https://raw.githubusercontent.com',
|
||||||
|
'https://ghraw.gkcoll.xyz',
|
||||||
|
'https://raw.fgit.mxtrans.net',
|
||||||
|
'https://github.moeyy.xyz/https://raw.githubusercontent.com',
|
||||||
|
'https://raw.fgit.cf',
|
||||||
|
]
|
||||||
|
|
||||||
async def get_response(retry = 0):
|
async def get_response(retry = 0):
|
||||||
if (retry > 10):
|
if (retry > 21):
|
||||||
logger.warning('请求源脚本内容失败')
|
logger.warning('请求源脚本内容失败')
|
||||||
return
|
return
|
||||||
baseurl = 'https://raw.githubusercontent.com/lxmusics/lx-music-api-server/main/lx-music-source-example.js'
|
baseurl = '/lxmusics/lx-music-api-server/main/lx-music-source-example.js'
|
||||||
|
jsdbaseurl = '/gh/lxmusics/lx-music-api-server@main/lx-music-source-example.js'
|
||||||
try:
|
try:
|
||||||
if (iscn and (retry % 2) == 0):
|
i = retry
|
||||||
req = await Httpx.AsyncRequest('https://mirror.ghproxy.com/' + baseurl)
|
if (i > 10):
|
||||||
else:
|
i = i - 11
|
||||||
req = await Httpx.AsyncRequest(baseurl)
|
if (i < 5):
|
||||||
|
req = await Httpx.AsyncRequest(jsd_mirror_list[retry] + jsdbaseurl)
|
||||||
|
elif (i < 11):
|
||||||
|
req = await Httpx.AsyncRequest(githun_raw_mirror_list[retry - 5] + baseurl)
|
||||||
|
if (not req.text.startswith('/*!')):
|
||||||
|
logger.info('疑似请求到了无效的内容,忽略')
|
||||||
|
raise Exception from None
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if (isinstance(e, RuntimeError)):
|
if (isinstance(e, RuntimeError)):
|
||||||
if ('Session is closed' in str(e)):
|
if ('Session is closed' in str(e)):
|
||||||
@ -35,7 +58,6 @@ async def get_response(retry = 0):
|
|||||||
return
|
return
|
||||||
return await get_response(retry + 1)
|
return await get_response(retry + 1)
|
||||||
return req
|
return req
|
||||||
|
|
||||||
async def get_script():
|
async def get_script():
|
||||||
req = await get_response()
|
req = await get_response()
|
||||||
if (req.status == 200):
|
if (req.status == 200):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user