feat: 将工具更名为 VideosDownTools,并完善黄豆登录与清单

This commit is contained in:
Nixevol
2026-10-25 01:58:29 +08:00
parent 7253217e18
commit 3c2105c786
27 changed files with 1349 additions and 237 deletions
+52 -7
View File
@@ -2,7 +2,16 @@ from server.services.huangdou.client import ApiError, TokenExpired, client
from server.services.huangdou.crypto import USER_AGENT
def device_info() -> dict:
def device_info(identity: str = "guest") -> dict:
if identity == "account":
client._ensure_fingerprint()
info = client.device_info
else:
if not client.guest_device_id:
client.roll_guest_fingerprint()
info = client.guest_device_info
if isinstance(info, dict) and info:
return dict(info)
return {
"browserName": "Chrome",
"language": "zh-CN",
@@ -33,8 +42,34 @@ def login_device(*, force_new: bool = False) -> dict:
return data
def user_info() -> dict:
data = client.request("/user/info", {}, auth=True)
def login_username(username: str, password: str, channel_code: str = "") -> dict:
data = client.request(
"/login/username",
{
"line_code": "china_1",
"share_code": "",
"channel_code": channel_code,
"username": username.strip(),
"password": password,
"clipboard_text": "",
"device_info": device_info("account"),
},
auth=False,
identity="account",
)
if not isinstance(data, dict):
raise RuntimeError("账号登录没有返回数据")
token = str(data.get("token") or "").strip()
if not token:
raise RuntimeError("账号登录没有返回 token")
client.account_token = token
client.account_username = username.strip()
client.save()
return data
def user_info(*, identity: str = "guest") -> dict:
data = client.request("/user/info", {}, auth=True, identity=identity)
return data if isinstance(data, dict) else {}
@@ -110,13 +145,21 @@ def limited_free(page: int = 1, size: int = 50) -> dict:
return data if isinstance(data, dict) else {}
def drama_detail(drama_id: str) -> dict:
data = client.request("/drama/detail", {"id": str(drama_id)}, auth=True)
def drama_detail(drama_id: str, *, identity: str = "guest") -> dict:
data = client.request("/drama/detail", {"id": str(drama_id)}, auth=True, identity=identity)
return data if isinstance(data, dict) else {}
def drama_play(drama_id: str, seq: int) -> dict:
data = client.request("/drama/play", {"id": str(drama_id), "seq": str(seq)}, auth=True)
def drama_play(drama_id: str, seq: int, *, identity: str = "guest") -> dict:
data = client.request("/drama/play", {"id": str(drama_id), "seq": str(seq)}, auth=True, identity=identity)
return data if isinstance(data, dict) else {}
def drama_buy(drama_id: str, seq: int, method: str = "") -> dict:
body = {"id": str(drama_id), "seq": str(seq)}
if method:
body["method"] = method
data = client.request("/drama/doBuy", body, auth=True, identity="account")
return data if isinstance(data, dict) else {}
@@ -141,7 +184,9 @@ __all__ = [
"drama_list",
"drama_play",
"limited_free",
"drama_buy",
"login_device",
"login_username",
"nav_block",
"nav_list",
"system_info",