# MeDBia Disc Scanner (macOS)

Runs on your **Mac** — polls the optical drive, reads the disc, sends the record to the remote Docker stack, ejects.

## One-time setup

```bash
# Install Python dependency
pip3 install requests

# Set your server URL and the API token from docker-compose.yml
export VIDEODB_URL=http://your-server:6761
export VIDEODB_TOKEN=change_this_secret_token
```

## Run

```bash
cd scanner
python3 scan_disc.py
```

Then insert discs one by one. Each disc is:
1. Detected (polled every 5 s)
2. Read — volume label, disc type, size, file/track count
3. Submitted to the remote videoDB
4. Ejected automatically

## Environment variables

| Variable         | Default                        | Description                           |
|------------------|--------------------------------|---------------------------------------|
| `VIDEODB_URL`    | `http://your-server:6761`      | Base URL of the Docker stack          |
| `VIDEODB_TOKEN`  | `change_this_secret_token`     | Must match `INGEST_API_TOKEN` in docker-compose.yml |
| `POLL_INTERVAL`  | `5`                            | Seconds between drive checks          |

## What gets indexed per disc

| Field        | Source                                      |
|--------------|---------------------------------------------|
| Title        | Volume label (disc name as burned)          |
| Media type   | Auto-detected: DVD / Blu-ray / CD           |
| Comment      | Track count (audio) or file count (data)    |
| File size    | Total used space on disc                    |
| Custom 1     | Raw drutil type string                      |
| Custom 2     | Track or file count (number only)           |

All entries are immediately visible and searchable in the videoDB web UI at `http://your-server:6761`.

## macOS permissions

If macOS asks for permission to control the disc drive or access `/Volumes/`, allow it. The script uses `drutil`, `diskutil`, and `df` — all standard macOS CLI tools, no third-party drivers needed.

## Blu-ray note

macOS does not include a Blu-ray filesystem driver by default. Blu-ray discs will show as unreadable in Finder but `drutil status` will still report `BD-ROM`. The scanner will detect the type from drutil and index it, but file listing will be unavailable. Volume label may show as the device node instead of the disc name in that case — you can edit the entry in the web UI afterwards.
