← back to Contact Mailer Ideas
render-all-pitches.sh
49 lines
#!/bin/bash
# Batch-render 30-sec VC pitch videos for ALL ideas. Concurrency=4.
set -u
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
TASKS=$(mktemp)
DONE_FILE=$(mktemp)
trap "rm -f $TASKS $DONE_FILE" EXIT
python3 "$SCRIPT_DIR/build-pitch-tasks.py" > "$TASKS"
COUNT=$(wc -l < "$TASKS" | tr -d ' ')
echo "[Render plan] $COUNT pitch videos, concurrency=4, est ~$((COUNT * 18 / 4 / 60)) min"
echo
MAX=4
# Read all tasks into array (bash 3.2 compatible, no mapfile)
LINES=()
while IFS= read -r line; do
LINES+=("$line")
done < "$TASKS"
i=0
for LINE in "${LINES[@]}"; do
IFS=$'\t' read -r BATCH IDX NAME SCORE HEADLINE SCRIPT <<< "$LINE"
i=$((i+1))
# Throttle: wait until job count drops
while [ "$(jobs -rp 2>/dev/null | wc -l | tr -d ' ')" -ge "$MAX" ]; do
sleep 0.3
done
(
if "$SCRIPT_DIR/render-pitch-video.sh" "$NAME" "$SCORE" "$HEADLINE" "$SCRIPT" > /dev/null 2>&1; then
printf "OK\t%s\n" "$NAME" >> "$DONE_FILE"
else
printf "FAIL\t%s\n" "$NAME" >> "$DONE_FILE"
fi
) &
done
wait
SUCCESS=$(grep -c '^OK' "$DONE_FILE" 2>/dev/null || echo 0)
FAIL=$(grep -c '^FAIL' "$DONE_FILE" 2>/dev/null || echo 0)
TOTAL=$(ls ~/Videos/shipped-apps/Pitch-*-$(date +%Y-%m-%d).mp4 2>/dev/null | wc -l | tr -d ' ')
echo "[Done] ok=$SUCCESS fail=$FAIL files_on_disk=$TOTAL"
echo "$(date -Iseconds) units=$COUNT workers=$MAX ok=$SUCCESS err=$FAIL task=\"vc-pitch-videos-all-ideas\"" >> ~/.claude/skills/max-it/runs.log
if [ "$FAIL" -gt 0 ]; then
echo "Fails:"
grep '^FAIL' "$DONE_FILE" | head -10
fi