- package hunyuan3dweb/ -> hy3d/ (imports: from hy3d import ...) - CLI: MiniMax-style verb/noun commands (quota/list/status/formats/ download/text/image/multi-view/sketch/animate/texture/topo/cancel/ share/auth/config), global --json/--cookies, env HY3D_COOKIES/HY3D_JSON - exit codes: 0 ok / 1 env / 2 auth-expired / 3 cookie-missing - generation commands support --wait polling with stderr progress - local images auto-upload to COS in image/multi-view/sketch/animate/texture/topo - old commands removed (no backwards compat) - config dir kept at ~/.config/hunyuan3dweb to preserve existing cookies - deps: requests>=2.32.3, browser extras cloakbrowser>=0.3.31/playwright>=1.40 - skill updated: bin/hy3d shim replaces driver.sh; all commands live-verified
45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
import os
|
|
import shutil
|
|
import tempfile
|
|
from pathlib import Path
|
|
from typing import Optional, Tuple
|
|
|
|
|
|
def get_config_dir() -> Path:
|
|
"""Return the user configuration directory (kept as `hunyuan3dweb` for path stability)."""
|
|
xdg = os.environ.get("XDG_CONFIG_HOME")
|
|
base = Path(xdg) if xdg else Path.home() / ".config"
|
|
path = base / "hunyuan3dweb"
|
|
path.mkdir(parents=True, exist_ok=True)
|
|
return path
|
|
|
|
|
|
def get_cookie_path() -> Path:
|
|
"""Return the path to the cookies file."""
|
|
return get_config_dir() / "cookies.txt"
|
|
|
|
|
|
def get_profile_dir() -> Path:
|
|
"""Return the path to the browser profile directory."""
|
|
path = get_config_dir() / "profile"
|
|
path.mkdir(parents=True, exist_ok=True)
|
|
return path
|
|
|
|
|
|
def prepare_profile_dir() -> Tuple[str, Optional[str]]:
|
|
"""
|
|
将标准 profile 复制到临时目录,避免 Chromium 锁冲突。
|
|
|
|
Returns:
|
|
(实际使用的 profile 路径, 临时目录路径或 None)。
|
|
如果使用了临时副本,调用者应在完成后用 shutil.rmtree 删除。
|
|
"""
|
|
standard = str(get_profile_dir())
|
|
if not os.path.exists(standard):
|
|
return standard, None
|
|
|
|
temp_root = tempfile.mkdtemp(prefix="hy3d-profile-")
|
|
temp_profile = os.path.join(temp_root, "profile")
|
|
shutil.copytree(standard, temp_profile, dirs_exist_ok=True)
|
|
return temp_profile, temp_root
|