From 12f9e90045ccba7161d01100a1d3197816ba3f93 Mon Sep 17 00:00:00 2001 From: helloplhm-qwq Date: Sun, 7 Jan 2024 12:27:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/lx_script.py | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/common/lx_script.py b/common/lx_script.py index d0e96e9..2cc4a1e 100644 --- a/common/lx_script.py +++ b/common/lx_script.py @@ -18,16 +18,39 @@ import re 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): - if (retry > 10): + if (retry > 21): logger.warning('请求源脚本内容失败') 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: - if (iscn and (retry % 2) == 0): - req = await Httpx.AsyncRequest('https://mirror.ghproxy.com/' + baseurl) - else: - req = await Httpx.AsyncRequest(baseurl) + i = retry + if (i > 10): + i = i - 11 + 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: if (isinstance(e, RuntimeError)): if ('Session is closed' in str(e)): @@ -35,7 +58,6 @@ async def get_response(retry = 0): return return await get_response(retry + 1) return req - async def get_script(): req = await get_response() if (req.status == 200):