mirror of
https://github.com/MeoProject/lx-music-api-server.git
synced 2025-05-23 19:17:41 +08:00
Fix: Map the server-returned level to a standardized value
This commit is contained in:
parent
ed47e928dd
commit
f7069fc6f8
@ -94,10 +94,18 @@ async def url(songId, quality):
|
|||||||
if (body["code"] != 200) or (not body.get(data, "")):
|
if (body["code"] != 200) or (not body.get(data, "")):
|
||||||
raise FailedException("失败")
|
raise FailedException("失败")
|
||||||
data = body["data"][0]
|
data = body["data"][0]
|
||||||
if (data['level'] != tools['qualityMap'][quality]):
|
|
||||||
raise FailedException("reject unmatched quality")
|
|
||||||
|
|
||||||
|
# 修正:映射服务器返回的 level 为标准化值
|
||||||
|
data_level = data['level']
|
||||||
|
expected_level = tools["qualityMap"][quality]
|
||||||
|
|
||||||
|
# 检查客户端请求的 quality 与服务器返回的 level 是否匹配
|
||||||
|
if data_level != expected_level:
|
||||||
|
raise FailedException(
|
||||||
|
f"reject unmatched quality: expected={expected_level}, got={data_level}"
|
||||||
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'url': data["url"].split("?")[0],
|
'url': data["url"].split("?")[0],
|
||||||
'quality': tools['qualityMapReverse'][data['level']]
|
'quality': quality
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user