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
5 changes: 5 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ VIDEO_FILENAME=video1.strm
WORKERS=4 # How many workers to use for scanning
VIDEO_START_TIME=10 # Start at 10 seconds to avoid ads
TMDB_API_KEY=your_tmdb_api_key

# Optional: Auto-mapping for media libraries without {imdb-...} folder names
# Comma-separated list of media directories to scan
# MEDIA_DIRS=/mnt/plex/Movies,/mnt/plex/TV Shows,/mnt/plex/Anime
# MAPPING_FILE=media_mapping.json
53 changes: 52 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,13 @@ WORKERS=4
VIDEO_START_TIME=10
```

- `SCAN_PATH`: Directory to scan for IMDb IDs
- `SCAN_PATH`: Directory to scan for IMDb IDs (used with `{imdb-ttXXXXXXX}` folder naming)
- `VIDEO_FILENAME`: Name of the .strm file to update
- `WORKERS`: Amount of workers to use
- `VIDEO_START_TIME`: Start time in seconds for the video (default: 10)
- `TMDB_API_KEY`: Your TMDB API key (required for auto-mapping, get one free at [themoviedb.org](https://www.themoviedb.org/settings/api))
- `MEDIA_DIRS`: *(Optional)* Comma-separated list of media directories for auto-mapping (see below)
- `MAPPING_FILE`: *(Optional)* Path to the mapping file (default: `media_mapping.json`)

### 3. Build and Run with Docker

Expand Down Expand Up @@ -123,6 +126,54 @@ This mode will:
- Skip movies without trailers
- Run in the background

## Auto-Mapping (no folder renaming required)

If your media folders use a standard `Title (Year)` naming convention (e.g., `Avatar (2009)`) instead of the `{imdb-ttXXXXXXX}` format, you can use the **auto-mapping** feature. It uses the TMDB API to automatically resolve IMDb IDs from your folder names.

### Setup

1. Get a free TMDB API key at [themoviedb.org](https://www.themoviedb.org/settings/api)
2. Add these variables to your `.env`:

```env
TMDB_API_KEY=your_tmdb_api_key
MEDIA_DIRS=/mnt/plex/Movies,/mnt/plex/TV Shows,/mnt/plex/Anime
```

The `MEDIA_DIRS` variable accepts a comma-separated list of your media library root directories. Trailerfin will automatically detect the media type (movie/tv) from the directory name.

### How it works

- On startup (and every ~1 hour), Trailerfin scans each directory in `MEDIA_DIRS`
- For each subfolder, it parses the title and year from the folder name
- It queries the TMDB API to find the matching title, then resolves the IMDb ID
- Results are cached in `media_mapping.json` so TMDB is only queried once per folder
- Folders that already use the `{imdb-...}` naming convention are skipped

### Manual mapping build

You can build or update the mapping manually:

```sh
python trailerfin.py --build-mapping
```

### Editing the mapping

The `media_mapping.json` file can be manually edited to fix incorrect matches:

```json
{
"/mnt/plex/Movies/Avatar (2009)": {
"imdb_id": "tt0499549",
"title": "Avatar",
"year": 2009
}
}
```

Set `"not_found": true` to skip a folder, or update `"imdb_id"` to correct a wrong match. Delete an entry to have Trailerfin retry the lookup on next scan.

## Features in Detail

### Ignore List
Expand Down
Loading