- 新增 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 路由验证通过
22 lines
789 B
Python
22 lines
789 B
Python
"""Bilibili 封面:搜索结果/合集条目已带封面;仅有 id 时回源 x/web-interface/view 取 pic。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from app.sdk.platforms.bili.util import fetch_view, normalize_cover, parse_song_id
|
|
|
|
|
|
async def get_pic(song_info: dict[str, Any]) -> str:
|
|
direct = str(song_info.get("img") or "")
|
|
if direct.startswith(("http://", "https://")):
|
|
return direct
|
|
bvid = str(song_info.get("bvid") or "") or parse_song_id(song_info.get("songmid"))["bvid"]
|
|
if not bvid:
|
|
return ""
|
|
try:
|
|
view = await fetch_view(bvid)
|
|
return normalize_cover(view.get("pic") or "")
|
|
except Exception: # noqa: BLE001 - 与原文一致:封面取不到返回空串,不影响调用方
|
|
return ""
|