feat: 增加桌面端登录、视频清单和封面缓存
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
from server.services.device import DeviceProfile
|
||||
from server.services.http import http
|
||||
|
||||
API_BASE = "https://apis.raptdrama.com"
|
||||
|
||||
|
||||
class RaptApi:
|
||||
def guest_token(self, device: DeviceProfile) -> str:
|
||||
data = self._post("/app/open/autologin", "", device, {})
|
||||
token = data.get("token") or ""
|
||||
if not token:
|
||||
raise RuntimeError("游客登录没有返回 token")
|
||||
return token
|
||||
|
||||
def email_token(self, email: str, password: str, device: DeviceProfile) -> str:
|
||||
data = self._post("/app/open/emailLogin", "", device, {
|
||||
"email": email,
|
||||
"password": password,
|
||||
})
|
||||
token = data.get("token") or ""
|
||||
if not token:
|
||||
raise RuntimeError("邮箱登录没有返回 token")
|
||||
return token
|
||||
|
||||
def user_info(self, token: str, device: DeviceProfile) -> dict:
|
||||
data = self._post("/app/user/getUserInfo", token, device, {})
|
||||
data.pop("token", None)
|
||||
data.pop("accessToken", None)
|
||||
return data
|
||||
|
||||
def _post(self, path: str, token: str, device: DeviceProfile, body: dict) -> dict:
|
||||
return http.request_json("POST", API_BASE + path, token, device, body)
|
||||
|
||||
|
||||
rapt = RaptApi()
|
||||
Reference in New Issue
Block a user