#!/usr/bin/env bash

set -euo pipefail

VENV="$HOME/whisper-srt"
TRANSLATOR="$HOME/bin/reel-translate.py"

if [[ $# -lt 2 ]]; then
    echo
    echo "Usage:"
    echo
    echo "  reel-translate <srt-file> <language> [language...]"
    echo
    echo "Examples:"
    echo
    echo "  reel-translate video.en_GB.srt French"
    echo "  reel-translate video.en_GB.srt French German Spanish"
    echo "  reel-translate video.en_GB.srt fr de es"
    echo
    exit 1
fi

if [[ ! -f "$VENV/bin/activate" ]]; then
    echo "Error: Python environment not found:"
    echo "$VENV"
    exit 1
fi

if [[ ! -f "$TRANSLATOR" ]]; then
    echo "Error: Translator not found:"
    echo "$TRANSLATOR"
    exit 1
fi

source "$VENV/bin/activate"
python "$TRANSLATOR" "$@"
