# Khanega — rclone Google Drive setup

One-time setup so the pipeline can pull lecture audio from your Drive.

## Step 1 — Authorize on your Mac (5 min)

### 1a. Install rclone locally on the Mac
```bash
brew install rclone
```
(or `curl https://rclone.org/install.sh | sudo bash`)

### 1b. Run the headless auth on your Mac
```bash
rclone authorize "drive" "eyJzY29wZSI6ImRyaXZlIn0"
```
This opens your browser → log in with your Google account that owns/has-access-to the Khanega folder → click Allow → terminal prints a long token blob (JSON starting with `{"access_token":...`).

**Copy that entire token blob** (including the curly braces).

## Step 2 — On the VPS (here), run:
```bash
rclone config
```

Walk through:
1. `n` — new remote
2. name: **`gdrive`**
3. Storage: pick `drive` (Google Drive — number varies by rclone version, look for it)
4. `client_id` — blank (Enter)
5. `client_secret` — blank (Enter)
6. scope: `1` (full access)
7. `service_account_file` — blank (Enter)
8. Advanced config — `n`
9. Use auto config — **`n`** (we're headless)
10. **Result of "rclone authorize..."**: paste the token blob from Step 1b
11. Configure as Shared Drive — `n` (unless it's actually a shared drive)
12. Keep this remote — `y`
13. `q` to quit

## Step 3 — Verify access to the Khanega folder

The folder ID from the URL is `160vGgXJbWSp68TfTjD7craJVPNeGWimS`.

```bash
# List files in the folder using its ID directly
rclone lsf --drive-root-folder-id 160vGgXJbWSp68TfTjD7craJVPNeGWimS gdrive:

# Total size of the folder
rclone size --drive-root-folder-id 160vGgXJbWSp68TfTjD7craJVPNeGWimS gdrive:
```

If the folder was shared with you (not owned), add `--drive-shared-with-me`:
```bash
rclone lsf --drive-shared-with-me gdrive: | grep -i khanega
```

## Step 4 — Download to the project dir

```bash
mkdir -p /data/cameron/life/projects/khanega/audio

rclone copy \
  --drive-root-folder-id 160vGgXJbWSp68TfTjD7craJVPNeGWimS \
  gdrive: \
  /data/cameron/life/projects/khanega/audio \
  --progress --transfers 4
```

(Use `--max-size 500M` to skip massive files while testing, or `--include "*.mp3" --include "*.m4a" --include "*.wav"` to filter audio only.)

## Step 5 — Run the pipeline

Once audio files land in `audio/`, run:
```bash
cd /data/cameron/life/projects/khanega
./.venv/bin/python transcribe.py audio/<filename>
./.venv/bin/python translate.py audio/<filename>
./.venv/bin/python build_srt.py audio/<filename>
```

See `README.md` for what each script produces.
