feat(python): 完成 Python 全量迁移——剩余平台、登录通道与公共层修复
- 新增 5sing/apple/xm/me/qt/lr 平台包与取流实现(含 xm-sign、MissEvan 签名、蜻蜓 HMAC、Apple developer token) - 新增 wy/kg/tx/lr 登录:扫码、手机号、账密(kg 20028 风控指纹)、cookie 绑定、kg/tx 续期 - request 层:保留多值 Set-Cookie;JSON body 紧凑化(修复 kg 网关验签);直连不经系统代理(对齐 Node) - 登录路由统一 Body(embed=True),修复扫码轮询 422;lifespan 接入登录续期调度 - ruff/format/pyright 全绿;14 平台真实联网与 HTTP 路由验证通过
This commit is contained in:
1 parent
800871ef6e
commit
dfc06bf4de
182 files changed
+26620
No files matched your search
@@ -0,0 +1,44 @@
|
||||
"""咪咕链接解析(对应 sdk/mg/index.ts 的 parseSong)。
|
||||
|
||||
歌曲:`https://music.migu.cn/v3/music/song/<contentId>` 或裸 contentId(6 位以上数字)。
|
||||
专辑/歌单分别复用 album / playlist 的链接解析。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from typing import Any
|
||||
|
||||
from app.sdk.platforms.mg.album import parse_album_link
|
||||
from app.sdk.platforms.mg.playlist import parse_playlist_link
|
||||
from app.sdk.platforms.mg.util import convert_item_to_song, fetch_song_detail
|
||||
|
||||
_SONG_PATTERNS = (
|
||||
re.compile(r"music\.migu\.cn/v3/music/song/(\d+)"),
|
||||
re.compile(r"^(\d{6,})$"),
|
||||
)
|
||||
|
||||
|
||||
async def parse_song(link: str) -> dict[str, Any]:
|
||||
raw = str(link or "")
|
||||
content_id = ""
|
||||
for pattern in _SONG_PATTERNS:
|
||||
match = pattern.search(raw)
|
||||
if match:
|
||||
content_id = match.group(1)
|
||||
break
|
||||
if not content_id:
|
||||
raise RuntimeError("无效的咪咕歌曲链接")
|
||||
item = await fetch_song_detail(content_id)
|
||||
song = convert_item_to_song(item, True)
|
||||
if song is None:
|
||||
raise RuntimeError("该歌曲没有可用格式")
|
||||
return song
|
||||
|
||||
|
||||
async def parse_album(link: str) -> dict[str, Any]:
|
||||
return await parse_album_link(link)
|
||||
|
||||
|
||||
async def parse_playlist(link: str) -> dict[str, Any]:
|
||||
return await parse_playlist_link(link)
|
||||
Reference in new issue
Block a user