douyinWEB/backend/app/config.py
eric d409e416da Ship physical dual-edge stack, Studio CDP live metrics, and ops tooling.
Capture Neko/WG/network hubs, Studio viewer charts, physical deploy docs, and one-shot scripts so VPS vs physical can be toggled later without losing WIP.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-04 22:42:40 -05:00

103 lines
3.8 KiB
Python

from __future__ import annotations
from pathlib import Path
from pydantic_settings import BaseSettings
ROOT = Path(__file__).resolve().parents[2]
BACKEND = Path(__file__).resolve().parents[1]
class Settings(BaseSettings):
api_host: str = "127.0.0.1"
api_port: int = 8000
cors_origins: str = (
"http://localhost:3000,http://127.0.0.1:3000,"
"http://localhost:5173,http://127.0.0.1:5173,"
"http://127.0.0.1:18574,http://localhost:18574"
)
pb_url: str = "http://127.0.0.1:8090"
pb_admin_email: str = "hackrobot@douyin.local"
pb_admin_password: str = "Xiao4669805@"
data_dir: Path = BACKEND / "data"
covers_dir: Path = BACKEND / "data" / "covers"
clips_dir: Path = BACKEND / "data" / "clips"
sqlite_path: Path = BACKEND / "data" / "monitor.db"
# Anti risk-control defaults — aligned with sh2 config.ini
# 循环时间(秒)=300, 同一时间访问网络的线程数=3 (we use 1 for safer mass poll)
max_concurrency: int = 1
min_request_gap_sec: float = 3.0
request_jitter_sec: float = 2.0
offline_interval_sec: float = 300.0
live_interval_sec: float = 120.0
error_backoff_base_sec: float = 60.0
error_backoff_max_sec: float = 600.0
global_pause_on_risk_sec: float = 90.0
capture_cover_on_start: bool = True
ffmpeg_bin: str = "ffmpeg"
# SeaweedFS S3 API (open-source object storage with F)
s3_enabled: bool = False
s3_endpoint: str = "http://127.0.0.1:8333"
s3_public_base: str = "" # e.g. http://107.173.30.245:8333
s3_access_key: str = "douyin"
s3_secret_key: str = "douyinweb_s3_2026"
s3_bucket: str = "douyin-covers"
s3_region: str = "us-east-1"
# Node sidecar: youtubei.js (https://github.com/LuanRT/YouTube.js)
youtube_svc_url: str = "http://127.0.0.1:8020"
# Optional: require X-API-Key on POST/PATCH/DELETE (leave empty to disable)
api_key: str = ""
# Public HTTPS origin, e.g. https://ypp.smallzhiyuns.com
public_base_url: str = ""
# Site login (whole-site protection)
auth_enabled: bool = True
admin_username: str = "hackrobot"
admin_password: str = "Xiao4669805@"
session_secret: str = "douyinweb-session-2026"
# Neko browser (per YouTube assign group) — US VPS direct, no ShellClash
neko_enabled: bool = True
neko_http_port_base: int = 9200
# Soft cap for docker compose / instance ids (keep ≤ edge Caddy/Nginx published /neko/N).
neko_max_instances: int = 64
# Path gateway :9199 — optional; dual-edge physical uses native Caddy/Nginx /neko/{id}.
neko_gateway_enabled: bool = False
neko_gateway_port: int = 9199
# 127.0.0.1 = VPS colocated; 0.0.0.0 = physical (reachable via WireGuard)
neko_http_bind: str = "127.0.0.1"
neko_webrtc_mux_base: int = 52300
neko_user_pass: str = "douyinweb"
neko_admin_pass: str = "Xiao4669805@"
# x86 VPS: google-chrome (sh2); ARM would use chromium
neko_image: str = "ghcr.io/m1k1o/neko/google-chrome:3.0.0"
neko_nat1to1: str = "" # empty → auto-detect public IP
neko_webrtc_icelite: str = "0" # sh2: OFF for remote ICE stability
neko_shm_size: str = "512mb"
neko_desktop_screen: str = "1024x576@10"
neko_max_fps: str = "10"
neko_video_bitrate: str = "700"
neko_start_url: str = (
"https://accounts.google.com/ServiceLogin?continue=https://studio.youtube.com/"
)
# 1 = Chrome managed policies force-install Tampermonkey + import Auto Dismiss
# (sh2 seed LevelDB in-repo is empty; jsonImport is the real script path)
neko_managed_policies: str = "1"
class Config:
env_prefix = "DY_"
env_file = ".env"
settings = Settings()
settings.data_dir.mkdir(parents=True, exist_ok=True)
settings.covers_dir.mkdir(parents=True, exist_ok=True)
settings.clips_dir.mkdir(parents=True, exist_ok=True)