fix: 黄豆按站点方式保持登录并自动切换播放线路

This commit is contained in:
Nixevol
2026-10-25 05:40:19 +08:00
parent 3fe936fe70
commit f53498f6e6
11 changed files with 444 additions and 197 deletions
+36 -2
View File
@@ -6,8 +6,6 @@ from server.services.huangdou.covers import covers as huangdou_covers
def enter(host: str = "") -> dict:
if host:
client.set_host(host)
client.account_token = ""
client.account_username = ""
client.roll_guest_fingerprint()
raw = api.login_device(force_new=False)
guest = _user_from_login(raw)
@@ -19,6 +17,7 @@ def enter(host: str = "") -> dict:
profile = public_profile(None)
client.profile = profile
client.save()
api.remember_api_lines()
return {"token": client.token, "profile": profile}
@@ -44,6 +43,7 @@ def login_account(username: str, password: str, rotate_fingerprint: bool = False
profile = public_profile(info if isinstance(info, dict) else {})
client.profile = profile
client.save()
api.remember_api_lines()
return {"token": client.token, "profile": profile}
@@ -169,6 +169,40 @@ def _truthy(value) -> bool:
return text in {"1", "true", "y", "yes", "vip"}
def _renew_account() -> bool:
from server.services.huangdou.accounts import load
username = client.account_username.strip()
if not username:
return False
password = ""
for item in load():
if item.get("username") == username:
password = str(item.get("password") or "")
break
if not password:
return False
try:
api.login_username(username, password)
except Exception:
return False
return bool(client.account_token)
def _renew_guest() -> bool:
if not client.guest_device_id:
return False
try:
api.login_device(force_new=False)
except Exception:
return False
return bool(client.token)
client.renew_account = _renew_account
client.renew_guest = _renew_guest
def _number(value) -> int:
try:
return int(float(str(value or "0")))