#!/bin/sh set -eu BASE_URL="${STORYFORGE_BASE_URL:-http://127.0.0.1:8081}" USERNAME="${STORYFORGE_USERNAME:-kris}" PASSWORD="${STORYFORGE_PASSWORD:-Asd123456.}" ACCOUNT_ID="${STORYFORGE_SMOKE_ACCOUNT_ID:-dyacct_c2b62842b228406cb48f05fac16fdfdf}" python3 - <<'PY' import json import os import urllib.request base = os.environ.get("BASE_URL", "http://127.0.0.1:8081").rstrip("/") username = os.environ.get("USERNAME", "kris") password = os.environ.get("PASSWORD", "Asd123456.") account_id = os.environ.get("ACCOUNT_ID", "dyacct_c2b62842b228406cb48f05fac16fdfdf") login_req = urllib.request.Request( base + "/v2/auth/login", data=json.dumps({"username": username, "password": password}).encode(), headers={"content-type": "application/json"}, ) with urllib.request.urlopen(login_req, timeout=20) as resp: login = json.load(resp) token = login["token"] headers = {"authorization": "Bearer " + token} checks = [ ("/v2/douyin/accounts", "accounts"), (f"/v2/douyin/accounts/{account_id}/workspace", "workspace"), (f"/v2/douyin/accounts/{account_id}/videos?limit=5&sort_by=score", "videos"), ] print("smoke login: ok") for path, label in checks: req = urllib.request.Request(base + path, headers=headers) with urllib.request.urlopen(req, timeout=30) as resp: payload = json.load(resp) if label == "accounts": summary = {"accounts": len(payload)} elif label == "workspace": summary = { "account": payload.get("account", {}).get("nickname"), "reports": len(payload.get("recent_reports") or []), "linked_accounts": len(payload.get("linked_accounts") or []), "high_score_threshold": (payload.get("video_workspace") or {}).get("high_score_threshold"), } else: items = payload.get("items") or [] summary = { "videos": len(items), "first_title": items[0].get("title") if items else None, "first_has_analysis": bool(items and items[0].get("latest_analysis")), } print(f"{label}: " + json.dumps(summary, ensure_ascii=False)) PY