mirror of
https://github.com/MeoProject/lx-music-api-server.git
synced 2025-07-07 15:04:24 +08:00
feat: 脚本下载优化
This commit is contained in:
@ -52,7 +52,8 @@ default = {
|
|||||||
"ports": [ 9763 ],
|
"ports": [ 9763 ],
|
||||||
"_ports-desc": "服务器启动时所使用的端口",
|
"_ports-desc": "服务器启动时所使用的端口",
|
||||||
"ssl_info": {
|
"ssl_info": {
|
||||||
"desc": "服务器https配置",
|
"desc": "服务器https配置,is_https是这个服务器是否是https服务器,如果你使用了反向代理来转发这个服务器,如果它使用了https,也请将它设置为true",
|
||||||
|
"is_https": False,
|
||||||
"enable": False,
|
"enable": False,
|
||||||
"ssl_ports": [ 443 ],
|
"ssl_ports": [ 443 ],
|
||||||
"path": {
|
"path": {
|
||||||
@ -85,9 +86,11 @@ default = {
|
|||||||
"intro": "修改为你的源脚本描述",
|
"intro": "修改为你的源脚本描述",
|
||||||
"author": "修改为你的源脚本作者",
|
"author": "修改为你的源脚本作者",
|
||||||
"version": "修改为你的源版本",
|
"version": "修改为你的源版本",
|
||||||
|
"filename": "lx-music-source.js",
|
||||||
|
"_filename-desc": "客户端保存脚本时的文件名(可能因浏览器不同出现不一样的情况)",
|
||||||
"dev": True,
|
"dev": True,
|
||||||
"quality": {
|
"quality": {
|
||||||
"kw": ["128k", "320k", "flac"],
|
"kw": ["128k"],
|
||||||
"kg": ["128k"],
|
"kg": ["128k"],
|
||||||
"tx": ["128k"],
|
"tx": ["128k"],
|
||||||
"wy": ["128k"],
|
"wy": ["128k"],
|
||||||
|
@ -79,6 +79,7 @@ async def generate_script_response(request):
|
|||||||
scriptLines = script.split('\n')
|
scriptLines = script.split('\n')
|
||||||
newScriptLines = []
|
newScriptLines = []
|
||||||
for line in scriptLines:
|
for line in scriptLines:
|
||||||
|
oline = line
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if (line.startswith('const API_URL')):
|
if (line.startswith('const API_URL')):
|
||||||
newScriptLines.append(f'const API_URL = "{request.scheme}://{request.host}"')
|
newScriptLines.append(f'const API_URL = "{request.scheme}://{request.host}"')
|
||||||
@ -95,14 +96,17 @@ async def generate_script_response(request):
|
|||||||
elif (line.startswith("const DEV_ENABLE ")):
|
elif (line.startswith("const DEV_ENABLE ")):
|
||||||
newScriptLines.append("const DEV_ENABLE = " + str(config.read_config("common.download_config.dev")).lower())
|
newScriptLines.append("const DEV_ENABLE = " + str(config.read_config("common.download_config.dev")).lower())
|
||||||
else:
|
else:
|
||||||
newScriptLines.append(line)
|
newScriptLines.append(oline)
|
||||||
r = '\n'.join(newScriptLines)
|
r = '\n'.join(newScriptLines)
|
||||||
|
|
||||||
r = re.sub(r'const MUSIC_QUALITY = {[^}]+}', f'const MUSIC_QUALITY = JSON.parse(\'{json.dumps(config.read_config("common.download_config.quality"))}\')', r)
|
r = re.sub(r'const MUSIC_QUALITY = {[^}]+}', f'const MUSIC_QUALITY = JSON.parse(\'{json.dumps(config.read_config("common.download_config.quality"))}\')', r)
|
||||||
|
|
||||||
return Response(text = r, content_type = 'text/javascript',
|
return Response(text = r, content_type = 'text/javascript',
|
||||||
headers = {
|
headers = {
|
||||||
'Content-Disposition': 'attachment; filename=lx-music-source.js'
|
'Content-Disposition': f'attachment; filename={
|
||||||
|
config.read_config("common.download_config.filename")
|
||||||
|
if config.read_config("common.download_config.filename").endswith(".js")
|
||||||
|
else (config.read_config("common.download_config.filename" + ".js"))}'
|
||||||
})
|
})
|
||||||
|
|
||||||
if (config.read_config('common.allow_download_script')):
|
if (config.read_config('common.allow_download_script')):
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# ----------------------------------------
|
# ----------------------------------------
|
||||||
# - mode: python -
|
# - mode: python -
|
||||||
# - author: helloplhm-qwq -
|
# - author: helloplhm-qwq -
|
||||||
# - name: kwdes.py -
|
# - name: encrypt.py -
|
||||||
# - project: lx-music-api-server -
|
# - project: lx-music-api-server -
|
||||||
# - license: MIT -
|
# - license: MIT -
|
||||||
# ----------------------------------------
|
# ----------------------------------------
|
||||||
|
Reference in New Issue
Block a user