prefetcharr

prefetcharr

Docker app from grtgbln's Repository

Overview

Let Sonarr fetch episodes on demand for a show you are watching on Jellyfin/Emby/Plex.

prefetcharr

Have Sonarr automatically fetch the next episodes of the show you’re watching on Jellyfin/Emby/Plex.

Details

prefetcharr periodically polls your media server for active playback sessions of TV shows. It then checks whether a configured number of successive episodes is available. If there are episodes missing, it asks Sonarr to search for them. Depending on the configuration, it searches the missing episodes individually or tries to fetch all seasons that contain them. If there are no more seasons left, the series is monitored for new seasons instead.

Build and install

To install, first ensure Rust is installed on your system by following the instructions at Install Rust, then run:

cargo install --git https://github.com/p-hueber/prefetcharr

Or with docker compose:

services:
  prefetcharr:
    image: phueber/prefetcharr:latest
    container_name: prefetcharr
    environment:
      - |
        PREFETCHARR_CONFIG=
        # Start of the configuration in TOML format.
       
        interval = 900           # Polling interval in seconds
        log_dir = "/log"         # Logging directory
        log_level = "Debug"      # `Trace`, `Debug`, `Info`, `Warn` or `Error`
        prefetch_num = 2         # Number of episodes to make available in advance
        request_seasons = true   # Always request full seasons to prefer season packs
        append_to_queue = false  # Experimental: Append upcoming episodes to the player's active queue.
                                 # Not supported by all clients. Not compatible with Tautulli.
        connection_retries = 6   # Number of retries for the initial connection probing

        [media_server]
        type = "Jellyfin"                       # `Jellyfin`, `Emby`, `Plex` or `Tautulli`
        url = "http://example.com/jellyfin"     # Jellyfin/Emby/Plex/Tautulli baseurl
        api_key = "<YOUR KEY HERE>"             # Jellyfin/Emby/Tautulli API key or plex server token
        # users = [ "John", "12345", "Axel F" ] # Optional: Only monitor sessions for specific user IDs or names
        # libraries = [ "TV Shows", "Anime" ]   # Optional: Only monitor sessions for specific libraries

        [sonarr]
        url = "http://example.com/sonarr" # Sonarr baseurl
        api_key = "<YOUR KEY HERE>"       # Sonarr API key
        # exclude_tag = "no_prefetch"     # Optional: Exclude series by tag

    volumes:
      - /path/to/log/dir:/log
      # Keep the config in a file instead of PREFETCHARR_CONFIG
      # - /path/to/config.toml:/config

Configuration

The configuration is written in TOML format. When running prefetcharr directly, you can pass the path of the configuration file using the --config command-line flag. For the Docker container, provide the entire configuration via the PREFETCHARR_CONFIG environment variable. A complete example can be found in the installation instructions for docker-compose above.

API keys

prefetcharr needs two different API keys to do its job.

sonarr.api_key

Go to Settings -> General -> Security and copy the API key.

media_server.api_key

The key to use and how to obtain it differs on the type of media server you use:

Jellyfin

Log in as an administrator and go to Administration -> Dashboard -> Advanced -> Api Keys. Add a new key or use an existing one.

Emby

Log in as an administrator, click on the gear on the top right and go to Advanced -> Api Keys. Add a new key or use an existing one.

Plex

You need to extract the server token from a configuration file and use it as the API key.

Plex via Tautulli

Log in and go to Settings -> Web Interface -> API. Copy the key and make sure Enable API is ticked.

Upgrading pilots

If you want to store pilot episodes only, prefetcharr can fetch the first season for you on demand.
This method works well for individual episodes but may encounter issues with season packs.
For this to function in Sonarr, grabbing the season pack must be considered an upgrade of the pilot episode. This can be achieved through a custom format. Import the custom format and configure a quality profile to prefer it.

How to use

Host installation

If you installed prefetcharr through cargo, you can get a description of the command-line interface by running prefetcharr --help.

Docker installation

Users utilizing Docker only need to start the container, e.g. using docker compose up -d prefetcharr. Once the container is running, you may want to check the logs for errors. You can do so by either calling docker logs prefetcharr or by checking the logging directory you configured.

Install Prefetcharr on Unraid in a few clicks.

Find Prefetcharr in Community Apps on your Unraid server, review the template, and click Install. Unraid handles the Docker app or plugin setup from the published template.

Open the Apps tab on your Unraid server Search Community Apps for Prefetcharr Review the template variables and paths Click Install

Requirements


        Requires a `config.toml` file to be mounted at `/config` before starting the container. Paste the PREFETCHARR_CONFIG details into the file: https://github.com/p-hueber/prefetcharr#build-and-install
    

Download Statistics

197,924
Total Downloads
11,660
This Month
13,477
Avg / Month

Total Downloads Over Time

Loading chart...

Details

Repository
phueber/prefetcharr:latest
Last Updated2026-05-01
First Seen2025-11-21

Runtime arguments

Network
bridge
Privileged
false

Template configuration

Config FilePath

Path to the config file

Target
/config
Default
/mnt/user/appdata/prefetcharr/config.toml
Value
/mnt/user/appdata/prefetcharr/config.toml
Log PathPath

Path to the log folder

Target
/log
Default
/mnt/user/appdata/prefetcharr/log
Value
/mnt/user/appdata/prefetcharr/log
Config ElementVariable

Environmental variable storing TOML data for config. Do NOT populate, use config file instead. If the config file cannot be read, this will be used as a fallback and forcibly error the application.

Target
PREFETCHARR_CONFIG
Default
Could not read from config file.
Value
Could not read from config file.