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,73 @@
|
||||
"""猫耳FM 广播剧集列表(对应 sdk/me/album.ts,web 通道,匿名免签)。
|
||||
|
||||
接口: https://www.missevan.com/dramaapi/getdramaepisodes?drama_id=&season=&page=&order=0&pageSize=
|
||||
结果在 info.episodes.episode[](name/sound_id/pay_type/vip);剧名在 info.drama.name。
|
||||
注意:getdrama(不带 type=2 时)的 info.episodes.episode 同样可用(MusicFree 插件用法),
|
||||
本接口支持翻页故用之。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import math
|
||||
import re
|
||||
from typing import Any
|
||||
|
||||
from app.sdk.common.request import http_fetch
|
||||
from app.sdk.common.utils import as_dict, as_list, format_play_time
|
||||
|
||||
EPISODES_URL = "https://www.missevan.com/dramaapi/getdramaepisodes"
|
||||
|
||||
|
||||
async def get_album_detail(drama_id_raw: str, page: int = 1, limit: int = 30) -> dict[str, Any]:
|
||||
# 搜索结果的剧条目带 d: 前缀(songmid="d:<id>"),这里剥掉
|
||||
drama_id = drama_id_raw[2:] if str(drama_id_raw).startswith("d:") else str(drama_id_raw)
|
||||
if not re.fullmatch(r"\d+", drama_id):
|
||||
raise RuntimeError("剧 id 无效")
|
||||
resp = await http_fetch(
|
||||
f"{EPISODES_URL}?drama_id={drama_id}&season=1&page={page}&order=0&pageSize={max(30, limit)}",
|
||||
headers={
|
||||
"User-Agent": (
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
|
||||
"(KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36"
|
||||
),
|
||||
"Referer": f"https://www.missevan.com/mdrama/drama/{drama_id}",
|
||||
"Accept": "application/json",
|
||||
},
|
||||
timeout=15_000,
|
||||
)
|
||||
body = as_dict(resp.body)
|
||||
if resp.status_code != 200 or body.get("success") is False:
|
||||
raise RuntimeError(str(body.get("info") or f"获取剧集失败(HTTP {resp.status_code})"))
|
||||
info = as_dict(body.get("info"))
|
||||
drama = as_dict(info.get("drama"))
|
||||
episodes = as_list(as_dict(info.get("episodes")).get("episode"))
|
||||
songs = []
|
||||
for item in episodes[:limit]:
|
||||
if not isinstance(item, dict):
|
||||
continue
|
||||
duration = item.get("duration")
|
||||
songs.append(
|
||||
{
|
||||
"songmid": str(item.get("sound_id")),
|
||||
"name": item.get("name") or "",
|
||||
"singer": drama.get("name") or "",
|
||||
"albumId": str(drama_id),
|
||||
"albumName": drama.get("name") or "",
|
||||
"interval": format_play_time(math.floor(float(duration) / 1000 + 0.5)) if duration else 0,
|
||||
"payPlay": int(item.get("pay_type") or 0) > 0,
|
||||
"img": drama.get("cover") or None,
|
||||
"lrc": "",
|
||||
"lrcx": "",
|
||||
"types": [],
|
||||
"_types": {},
|
||||
"disabled": False,
|
||||
}
|
||||
)
|
||||
return {
|
||||
"info": {"name": drama.get("name") or str(drama_id), "total": len(episodes)},
|
||||
"list": songs,
|
||||
"total": len(episodes),
|
||||
"limit": limit,
|
||||
"allPage": 1,
|
||||
"source": "me",
|
||||
}
|
||||
Reference in new issue
Block a user