feat: 补全短剧全量清单并接入 DramaBox 官网登录

This commit is contained in:
Nixevol
2026-10-22 02:20:16 +08:00
parent 39774ad9cc
commit 00e78661a7
22 changed files with 894 additions and 194 deletions
+59
View File
@@ -10,6 +10,65 @@ def enter(language: str = "") -> dict:
return client.enter(language or client.language or DEFAULT_LANGUAGE)
def apply_account(language: str, user: dict) -> dict:
if not isinstance(user, dict):
raise RuntimeError("还没有登录成功")
web_token = str(user.get("token") or "").strip()
if not web_token or not _logged_in(user.get("isLogin")):
raise RuntimeError("还没有登录成功")
locale = client.enter(language or client.language or DEFAULT_LANGUAGE)["profile"]
client.web_token = web_token
profile = _account_profile(locale, user)
client.profile = profile
client.save()
return {"token": client.token, "profile": profile}
def _logged_in(value) -> bool:
if value is True:
return True
if isinstance(value, (int, float)) and int(value) == 1:
return True
text = str(value or "").strip().lower()
return text in {"1", "true", "yes"}
def _account_profile(locale: dict, user: dict) -> dict:
nickname = str(user.get("nickname") or user.get("name") or user.get("email") or locale.get("country") or "").strip()
email = str(user.get("email") or "").strip()
avatar = str(user.get("avatar") or user.get("userLogo") or user.get("avatarNumUrl") or "").strip()
if not avatar.startswith(("http://", "https://")):
avatar = ""
vip = _logged_in(user.get("isVip"))
return {
"id": user.get("uid") or user.get("id") or "",
"username": email or nickname,
"nickname": nickname or "DramaBox",
"email": email,
"phone": "",
"badge": "VIP" if vip else "",
"vipday": 1 if vip else 0,
"score": _number(user.get("coins")),
"watched": 0,
"rewards": _number(user.get("bonus")),
"login_day": 0,
"country": locale.get("country") or "",
"language": locale.get("language") or "",
"native": locale.get("native") or "",
"locale": locale.get("locale") or locale.get("id") or "",
"loginType": str(user.get("loginType") or ""),
"has_login": "1",
"avatarNumUrl": avatar,
}
def _number(value) -> int:
try:
return int(float(str(value or "0")))
except (TypeError, ValueError):
return 0
def current(token: str) -> dict:
token = (token or "").strip()
if not token: