Files
MusicServer/app/sdk/platforms/lr/menu.py
T
snowy-yang dfc06bf4de 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 路由验证通过
2026-10-23 21:55:45 +08:00

34 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""懒人听书章节列表(对应 sdk/lr/menu.ts,web 通道,匿名免签)。
接口: https://m.lrts.me/ajax/getBookMenu?bookId=&pageNum=&pageSize=&sortType=0
实测(2026-10-02)匿名可用;章节条目 {section, name, listenPrice, state}
注意:专辑类内容用 getAlbumAudios(entityType=2),本实现仅收书(entityType=3)。
"""
from __future__ import annotations
from typing import Any
from app.sdk.common.request import http_fetch
from app.sdk.common.utils import as_dict, as_list
UA_MI = (
"Mozilla/5.0 (Linux; U; Android 4.1.1; zh-cn; MI2 Build/JRO03L) AppleWebKit/534.30 "
"(KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 XiaoMi/MiuiBrowser/1.0"
)
MENU_URL = "https://m.lrts.me/ajax/getBookMenu"
async def get_book_menu(book_id: str, page: int = 1, limit: int = 30) -> dict[str, Any]:
resp = await http_fetch(
f"{MENU_URL}?bookId={book_id}&pageNum={page}&pageSize={max(30, limit)}&sortType=0",
headers={"User-Agent": UA_MI, "Referer": "https://m.lrts.me/"},
timeout=15_000,
)
if resp.status_code != 200:
raise RuntimeError(f"获取章节失败(HTTP {resp.status_code})")
body = as_dict(resp.body)
if body.get("status") == 1 or not body.get("list"):
raise RuntimeError(str(body.get("msg") or "获取章节失败"))
return {"total": int(body.get("sections") or 0), "list": as_list(body.get("list"))}