Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Configuration file, can hold secrets
scripts.conf
# node
node_modules
66 changes: 64 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ This repository contains shell scripts and configuration files for Radarr automa
- `radarr/connect/scripts_common.sh` - Shared library sourced by connect scripts (config loading, executable checks, Radarr API helpers).
- `radarr/auto_quality_switch.sh` - Switches movies from Remux-only to WebDL profiles when no physical release appears within a statistical threshold.
- `radarr/auto_quality_switch_reverse.sh` - Switches movies back to Remux-only when physical release dates appear for previously switched movies.
- `radarr/fetch_physical_dates.sh` - Searches Blu-ray.com for physical release dates missing from Radarr, logs results for TMDB submission.
- `radarr/tmdb_login.sh` - Playwright-based TMDB login script, exports session cookies for curl-based automation.
- `radarr/push_physical_to_tmdb.sh` - Pushes physical release dates to TMDB via their website's Kendo grid API.

---

Expand Down Expand Up @@ -110,6 +113,51 @@ Event types: `Test`, `MovieAdded`, `Download`, `Bulk`
./radarr/auto_quality_switch_reverse.sh --apply
```

**Run the physical release date lookup:**
```bash
./radarr/fetch_physical_dates.sh
```

**Run with batch limit:**
```bash
./radarr/fetch_physical_dates.sh --limit 20
```

**Export results to JSON:**
```bash
./radarr/fetch_physical_dates.sh --export dates.json
```

**Export results to CSV:**
```bash
./radarr/fetch_physical_dates.sh --export dates.csv --csv
```

**Run the TMDB login script (requires display/Xvfb):**
```bash
./radarr/tmdb_login.sh
```

**Run the TMDB login with custom cookie output:**
```bash
./radarr/tmdb_login.sh --cookies /path/to/cookies.txt
```

**Push a single release date to TMDB:**
```bash
./radarr/push_physical_to_tmdb.sh <tmdb_id> <date> [title]
```

**Push release dates from pipe:**
```bash
./radarr/fetch_physical_dates.sh --json --quiet | ./radarr/push_physical_to_tmdb.sh
```

**Dry-run mode:**
```bash
./radarr/push_physical_to_tmdb.sh --dry-run 123456 2025-01-15 "Movie Title"
```

### Testing

There are no formal test suites in this project. Manual testing can be performed by:
Expand Down Expand Up @@ -293,10 +341,11 @@ radarr/connect/
radarr/
auto_quality_switch.sh # Forward script: Remux-only → WebDL
auto_quality_switch_reverse.sh # Reverse script: WebDL → Remux-only
fetch_physical_dates.sh # Blu-ray.com physical release date lookup
tmdb_login.sh # Playwright-based TMDB cookie export
push_physical_to_tmdb.sh # Push release dates to TMDB via curl

docs/
quality-switch-spec.md # Forward script specification
quality-switch-reverse-spec.md # Reverse script specification
cookie-extraction.md # Guide for exporting YouTube cookies for yt-dlp
```

Expand Down Expand Up @@ -324,6 +373,19 @@ Required executables for `auto_quality_switch.sh` and `auto_quality_switch_rever
- curl
- jq

Required executables for `fetch_physical_dates.sh` (checked at runtime):
- curl
- jq

Required executables for `tmdb_login.sh` (checked at runtime):
- node (with playwright package)

Required executables for `push_physical_to_tmdb.sh` (checked at runtime):
- curl
- jq
- grep
- sed

---

## Notes
Expand Down
142 changes: 142 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,148 @@ See the sample file for all available settings with documentation.

---

### fetch_physical_dates.sh

Searches Blu-ray.com for physical release dates missing from Radarr. Useful
when TMDB hasn't listed a release date yet (e.g. Supergirl 2026 had a Blu-ray
planned for Sep 08 2026 before TMDB had it).

Outputs results as table, JSON, or CSV for manual TMDB submission.

#### Quick start

```sh
# Preview — check 3 movies, show debug output
./radarr/fetch_physical_dates.sh --limit 3 --debug

# Check all movies without physical release dates
./radarr/fetch_physical_dates.sh

# Export to JSON file
./radarr/fetch_physical_dates.sh --export dates.json

# Export to CSV
./radarr/fetch_physical_dates.sh --export dates.csv --csv
```

#### Flags

| Flag | Effect |
|------|--------|
| `--limit N` | Process max N movies per run (batch size) |
| `--export <file>` | Write results to file (JSON or CSV) |
| `--csv` | Export as CSV (default: JSON) |
| `-j`, `--json` | Output machine-readable JSON to stdout |
| `-q`, `--quiet` | Suppress table output |
| `-d`, `--debug` | Verbose debug logging to stderr |
| `--country <code>` | Override country filter (default: US) |

#### Scheduling

Run periodically to catch new releases:

```cron
# Weekly, check 50 movies at a time
0 8 * * 1 /path/to/radarr/fetch_physical_dates.sh --limit 50 --export /var/log/physical-dates.json >> /var/log/fetch-physical-dates.log 2>&1
```

---

### tmdb_login.sh

Playwright-based TMDB login script that exports session cookies for
curl-based automation. Solves AWS WAF JavaScript challenge that blocks
automated requests.

Run once on a machine with a display (or Xvfb). The exported cookie
file works with both `push_physical_to_tmdb.sh` and `yt-dlp`.

#### Quick start

```sh
# Login and export cookies
./radarr/tmdb_login.sh

# Export to custom location
./radarr/tmdb_login.sh --cookies /path/to/cookies.txt
```

#### Prerequisites

- Node.js with Playwright package installed
- Chromium browser (installed by Playwright)
- Display server or Xvfb for headed mode

```sh
npm install playwright
npx playwright install chromium
```

#### Flags

| Flag | Effect |
|------|--------|
| `--cookies <file>` | Output cookie file path (default: `~/.tmdb_cookies.txt`) |
| `-d`, `--debug` | Verbose debug logging to stderr |

---

### push_physical_to_tmdb.sh

Pushes physical release dates to TMDB via their website's Kendo grid
REST API. Uses session cookies from `tmdb_login.sh`.

Accepts single movies via arguments or batch processing via pipe from
`fetch_physical_dates.sh`.

#### Quick start

```sh
# Single movie
./radarr/push_physical_to_tmdb.sh 123456 2026-09-08 "Movie Title"

# Pipeline from fetch_physical_dates.sh
./radarr/fetch_physical_dates.sh --json --quiet | ./radarr/push_physical_to_tmdb.sh

# Dry-run mode
./radarr/push_physical_to_tmdb.sh --dry-run 123456 2026-09-08 "Movie Title"
```

#### Prerequisites

- `curl`, `jq`, `grep`, `sed` (POSIX tools)
- Cookie file from `tmdb_login.sh` (default: `~/.tmdb_cookies.txt`)

Set `TMDB_COOKIE_FILE` in `scripts.conf` to use a custom path:

```sh
TMDB_COOKIE_FILE="/path/to/cookies.txt"
```

#### Flags

| Flag | Effect |
|------|--------|
| `--dry-run` | Show what would be submitted, don't POST |
| `--country <code>` | ISO 3166-1 country code (default: US) |
| `--language <code>` | ISO 639-1 language code (default: en) |
| `--type <N>` | Release type 1-7 (default: 5 = Physical) |
| `--note <text>` | Note field (default: "Physical release") |
| `--cookies <file>` | Cookie file path (default: `~/.tmdb_cookies.txt`) |
| `--rate-limit <s>` | Seconds between requests in pipe mode (default: 1) |
| `-d`, `--debug` | Verbose debug logging to stderr |

#### Scheduling

Run after `fetch_physical_dates.sh` to push found dates:

```cron
# Weekly, push dates to TMDB
0 9 * * 1 /path/to/radarr/fetch_physical_dates.sh --json --quiet | /path/to/radarr/push_physical_to_tmdb.sh >> /var/log/push-physical.log 2>&1
```

---

## Contributing

This project follows [Conventional Commits](https://www.conventionalcommits.org/) and the conventions documented in [AGENTS.md](AGENTS.md).
Expand Down
Loading