feat: tx源cdn地址切换

This commit is contained in:
helloplhm-qwq 2023-11-11 21:12:13 +08:00
parent 0618b30dbe
commit aad3a71427
No known key found for this signature in database
GPG Key ID: 6BE1B64B905567C7
3 changed files with 21 additions and 16 deletions

View File

@ -39,6 +39,7 @@ tools = jsobject({
"loginuin": config.read_config("module.tx.user.uin"), "loginuin": config.read_config("module.tx.user.uin"),
"guid": config.read_config("module.tx.vkeyserver.guid"), "guid": config.read_config("module.tx.vkeyserver.guid"),
"uin": config.read_config("module.tx.vkeyserver.uin"), "uin": config.read_config("module.tx.vkeyserver.uin"),
"cdnaddr": config.read_config("module.tx.cdnaddr") if config.read_config("module.tx.cdnaddr") else 'http://ws.stream.qqmusic.qq.com/',
}) })
@ -81,4 +82,4 @@ async def url(songId, quality):
# js const { purl } = data.req_0.data.midurlinfo[0] # js const { purl } = data.req_0.data.midurlinfo[0]
if (not body.req_0.data.midurlinfo[0]['purl']): if (not body.req_0.data.midurlinfo[0]['purl']):
raise FailedException('failed') raise FailedException('failed')
return 'http://ws.stream.qqmusic.qq.com/' + body.req_0.data.midurlinfo[0]['purl'] return tools.cdnaddr + body.req_0.data.midurlinfo[0]['purl']

View File

@ -141,7 +141,8 @@ default = {
"qqmusic_key": "", "qqmusic_key": "",
"uin": "", "uin": "",
"_uin-desc": "key对应的QQ号" "_uin-desc": "key对应的QQ号"
} },
"cdnaddr": "http://ws.stream.qqmusic.qq.com/",
}, },
"wy": { "wy": {
"desc": "网易云音乐相关配置", "desc": "网易云音乐相关配置",
@ -360,21 +361,25 @@ def push_to_list(key, obj):
def read_config(key): def read_config(key):
config = variable.config try:
keys = key.split('.') config = variable.config
value = config keys = key.split('.')
for k in keys: value = config
if isinstance(value, dict): for k in keys:
if k not in value and keys.index(k) != len(keys) - 1: if isinstance(value, dict):
value[k] = {} if k not in value and keys.index(k) != len(keys) - 1:
elif k not in value and keys.index(k) == len(keys) - 1: value[k] = {}
elif k not in value and keys.index(k) == len(keys) - 1:
value = None
value = value[k]
else:
value = None value = None
value = value[k] break
else:
value = None
break
return value return value
except:
logger.warning(f'配置文件{key}不存在')
return None
def initConfig(): def initConfig():

View File

@ -11,7 +11,6 @@
import logging import logging
import colorlog import colorlog
import os import os
import traceback
from pygments import highlight from pygments import highlight
from pygments.lexers import PythonLexer from pygments.lexers import PythonLexer
from pygments.formatters import TerminalFormatter from pygments.formatters import TerminalFormatter