Skip to content

Commit

Permalink
feat: wyy音质检查
Browse files Browse the repository at this point in the history
  • Loading branch information
helloplhm-qwq committed Dec 2, 2023
1 parent 3d2d241 commit 225753a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 6 additions & 3 deletions apis/wy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
'320k': 'exhigh',
'flac': 'lossless',
'flac24bit': 'hires',
"jyeffect": "jyeffect",
"jysky": "jysky",
"jymaster": "jymaster",
"dolby": "jyeffect",
"sky": "jysky",
"master": "jymaster",
},
'cookie': config.read_config('module.wy.user.cookie'),
}
Expand All @@ -43,4 +43,7 @@ async def url(songId, quality):
body = json.loads(req.text)
if (not body.get("data") or (not body.get("data")) or (not body.get("data")[0].get("url"))):
raise FailedException("failed")
if (config.read_config('module.wy.reject_unmatched_quality')):
if (body['data'][0]['level'] != tools['qualityMap'][quality]):
raise FailedException("reject unmatched quality")
return body["data"][0]["url"].split("?")[0]
4 changes: 3 additions & 1 deletion common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ class ConfigReadException(Exception):
"user": {
"desc": "账号cookie数据,可以通过浏览器获取,需要vip账号来获取会员歌曲,如果没有请留为空值",
"cookie": ""
}
},
"reject_unmatcher_quality": True,
"_reject_unmatcher_quality-desc": "是否拒绝不匹配的音质(默认拒绝),网易云API在当前环境无法获取该音质时会自动将低音质,开启此功能将拒绝被降级的音质返回",
},
"mg": {
"desc": "咪咕音乐相关配置",
Expand Down

0 comments on commit 225753a

Please sign in to comment.