hit-cxf
2026-05-31 0bc7753fba9b44d4caa5d12bc4075fd402aa689a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/usr/bin/env bash
# One-click installer for Video-Claw.
 
set -euo pipefail
 
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BACKEND_DIR="$ROOT_DIR/backend"
FRONTEND_DIR="$ROOT_DIR/frontend"
 
info() {
  printf "\033[1;34m[install]\033[0m %s\n" "$1"
}
 
warn() {
  printf "\033[1;33m[install]\033[0m %s\n" "$1"
}
 
fail() {
  printf "\033[1;31m[install]\033[0m %s\n" "$1" >&2
  exit 1
}
 
check_command() {
  command -v "$1" >/dev/null 2>&1 || fail "$2"
}
 
check_python() {
  check_command python3 "Python 3.9+ is required. Please install Python first."
  python3 - <<'PY'
import sys
if sys.version_info < (3, 9):
    raise SystemExit("Python 3.9+ is required.")
print(f"Python {sys.version.split()[0]}")
PY
}
 
check_ffmpeg() {
  if ! command -v ffmpeg >/dev/null 2>&1; then
    warn "ffmpeg was not found. Video concatenation and audio/video post-processing will be unavailable."
    return 0
  fi
}
 
ensure_uv() {
  if command -v uv >/dev/null 2>&1; then
    return 0
  fi
 
  warn "uv was not found. Installing uv with python3 -m pip..."
  python3 -m pip install --user uv
 
  if ! command -v uv >/dev/null 2>&1; then
    warn "uv is still not on PATH. Falling back to venv + pip for backend dependencies."
    return 1
  fi
}
 
install_backend() {
  info "Installing backend dependencies..."
  cd "$BACKEND_DIR"
 
  if [ ! -f "config.yaml" ] && [ -f "config.yaml.example" ]; then
    cp config.yaml.example config.yaml
    warn "Created backend config.yaml from config.yaml.example. Fill in API keys before generating videos."
  fi
 
  if ensure_uv; then
    uv sync
  else
    python3 -m venv venv
    # shellcheck disable=SC1091
    source venv/bin/activate
    python -m pip install --upgrade pip
    python -m pip install -r requirements.txt
  fi
}
 
install_frontend() {
  info "Installing frontend dependencies..."
  cd "$FRONTEND_DIR"
 
  check_command node "Node.js 18+ is required. Please install Node.js first."
  check_command npm "npm is required. Please install npm first."
 
  if [ -f "package-lock.json" ]; then
    npm ci
  else
    npm install
  fi
 
  if [ "${AIGC_DIRECTOR_SKIP_FRONTEND_BUILD:-0}" = "1" ]; then
    warn "Skipping frontend build because AIGC_DIRECTOR_SKIP_FRONTEND_BUILD=1."
  else
    npm run build
  fi
}
 
main() {
  info "Video-Claw one-click install"
  check_python
  check_ffmpeg
  install_backend
  install_frontend
 
  cat <<EOF
 
Video-Claw installation complete.
 
Next steps:
  1. Edit backend API keys:
     $BACKEND_DIR/config.yaml
 
  2. Start backend:
     cd "$BACKEND_DIR"
     uv run python api_server.py
     # or, if uv was unavailable:
     source venv/bin/activate && python api_server.py
 
  3. Start frontend in a new terminal:
     cd "$FRONTEND_DIR"
     npm start
 
URLs:
  Backend:  http://localhost:8000/api/health
  Frontend: http://localhost:3000
EOF
}
 
main "$@"