fix: 黄豆按站点方式保持登录并自动切换播放线路
This commit is contained in:
@@ -50,7 +50,6 @@ class LoginBody(BaseModel):
|
||||
host: str = ""
|
||||
username: str = ""
|
||||
password: str = ""
|
||||
line: str = ""
|
||||
|
||||
|
||||
class AccountBody(BaseModel):
|
||||
@@ -116,16 +115,9 @@ def save_accounts(body: SavedAccountsBody):
|
||||
return {"accounts": hd_accounts.replace([item.model_dump() for item in body.accounts])}
|
||||
|
||||
|
||||
@router.post("/lines")
|
||||
def list_lines(body: TokenBody):
|
||||
return call(lambda: {"lines": hd_playlist.available_lines(body.host)})
|
||||
|
||||
|
||||
@router.post("/login")
|
||||
def login(body: LoginBody):
|
||||
def action():
|
||||
client.play_line = (body.line or "").strip()
|
||||
client.save()
|
||||
entered = hd_login.enter(body.host)
|
||||
if body.username.strip() and body.password:
|
||||
return hd_login.login_account(body.username, body.password)
|
||||
@@ -221,6 +213,7 @@ def list_episodes(body: PlayBody):
|
||||
"type": ep.get("type") or "",
|
||||
"media": "file" if (ep.get("src_kind") == "file" or is_direct_media(ep.get("src") or "")) else "hls",
|
||||
"is_preview": bool(ep.get("is_preview")),
|
||||
"lines": len(ep.get("line_urls") or []),
|
||||
"preview_seconds": ep.get("preview_seconds") or 0,
|
||||
"locked_reason": ep.get("locked_reason") or "",
|
||||
}
|
||||
@@ -291,11 +284,14 @@ def play_key(vid: str, cid: int):
|
||||
|
||||
|
||||
@router.get("/play/{vid}/{cid}/index.m3u8")
|
||||
def episode_playlist(vid: str, cid: int):
|
||||
def episode_playlist(vid: str, cid: int, line: int = 0):
|
||||
row = hd_playlist.episode_src(vid, cid)
|
||||
src = str(row.get("src") or "").strip()
|
||||
src = hd_playlist.pick_line(row, line)
|
||||
if not src:
|
||||
raise HTTPException(status_code=404, detail=row.get("locked_reason") or "这一集还没有可播放的地址")
|
||||
detail = row.get("locked_reason") or "这一集还没有可播放的地址"
|
||||
if line > 0:
|
||||
detail = "没有下一条线路"
|
||||
raise HTTPException(status_code=404, detail=detail)
|
||||
try:
|
||||
text = hd_playlist.playback_playlist(src)
|
||||
key = str(row.get("hls_key") or "").strip()
|
||||
|
||||
Reference in New Issue
Block a user