Files
RaptDramaDump/server/services/dramabox/login.py
T

28 lines
747 B
Python

from server.services.dramabox.client import client
from server.services.dramabox.locales import DEFAULT_LANGUAGE, public_list
def languages() -> list[dict]:
return public_list()
def enter(language: str = "") -> dict:
return client.enter(language or client.language or DEFAULT_LANGUAGE)
def current(token: str) -> dict:
token = (token or "").strip()
if not token:
raise RuntimeError("请先选择地区")
if token != client.token or not client.profile:
raise RuntimeError("登录已失效")
return {"token": client.token, "profile": client.profile}
def logout(token: str) -> None:
if token and token == client.token:
client.clear()
return
if not token:
client.clear()