- 新增 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 路由验证通过
52 lines
1.5 KiB
Python
52 lines
1.5 KiB
Python
"""系统路由 —— 健康检查与平台能力清单。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import time
|
|
from typing import Any
|
|
|
|
from app.http.envelope import ok
|
|
from app.sdk import SUPPORTED_SOURCES, support_quality
|
|
from app.sdk.platforms._base import capability_map
|
|
from fastapi import APIRouter, Request
|
|
|
|
router = APIRouter(tags=["系统"])
|
|
|
|
|
|
@router.get(
|
|
"/health",
|
|
summary="健康检查",
|
|
description="返回运行时长与已接入平台数,可用于探活与监控。",
|
|
)
|
|
async def health(request: Request) -> Any:
|
|
started_at = getattr(request.app.state, "started_at", None) or time.time()
|
|
return ok(
|
|
{
|
|
"status": "ok",
|
|
"uptime": round(time.time() - started_at),
|
|
"platforms": len(SUPPORTED_SOURCES),
|
|
}
|
|
)
|
|
|
|
|
|
@router.get(
|
|
"/sources",
|
|
summary="获取支持的平台",
|
|
description="返回各平台的音质支持与能力(search/url/lyric/pic/boards/hotSearch/songList/"
|
|
"singer/album/albumSearch/playlist/playlistSearch/playlistCategories/parse/userPlaylist)。"
|
|
"音质为 SDK 官方直连接口的支持范围。",
|
|
)
|
|
async def sources() -> Any:
|
|
platforms: list[dict[str, Any]] = []
|
|
for item in SUPPORTED_SOURCES:
|
|
module = item["module"]
|
|
platforms.append(
|
|
{
|
|
"id": item["id"],
|
|
"name": item["name"],
|
|
"qualities": support_quality.get(item["id"], []),
|
|
"capabilities": capability_map(module),
|
|
}
|
|
)
|
|
return ok({"platforms": platforms})
|