Note: this is the Legacy v2 Wiki. The new V3 Wiki can be found at the Servarr Wiki.
If you're looking to trigger a custom script in your download client to tell Sonarr when to update, you can find more details here. Scripts are added to Sonarr via the Connect Settings page.
Overview
Sonarr can execute a custom script when an episode is newly imported or renamed and depending on the action, different parameters are supplied. They are passed to the script through environment variables which allows for more flexibility in what is sent to the script and in no particular order.
Environment Variables
On Grab
Environment Variable | Details |
---|---|
sonarr_eventtype | Grab |
sonarr_series_id | Internal ID of the series |
sonarr_series_title | Title of the series |
sonarr_series_tvdbid | TVDB ID for the series |
sonarr_series_tvmazeid | TVMaze ID for the series |
sonarr_series_imdbid | IMDB ID for the series |
sonarr_series_type | Type of the series, Anime, Daily or Standard |
sonarr_release_episodecount | Number of episodes in the release |
sonarr_release_seasonnumber | Season number from release |
sonarr_release_episodenumbers | Comma separated list of episode numbers |
sonarr_release_episodeairdates | Air date from original network |
sonarr_release_episodeairdatesutc | Air Date with Time in UTC |
sonarr_release_episodetitles | Pipe (| ) separated list of episode titles |
sonarr_release_title | NZB/Torrent title |
sonarr_release_indexer | Indexer where the release was grabbed |
sonarr_release_size | Size of the release reported by the indexer |
sonarr_release_quality | Quality name from Sonarr |
sonarr_release_qualityversion | 1 is the default, 2 for proper, 3+ could be used for anime versions |
sonarr_release_releasegroup | Release Group, will not be set if it is unknown |
sonarr_download_id | The hash of the torrent/NZB file downloaded (used to uniquely identify the download in the download client) |
On Download/On Upgrade
Environment Variable | Details |
---|---|
sonarr_eventtype | Download |
sonarr_isupgrade | True when an an existing file is upgraded, otherwise False |
sonarr_series_id | Internal ID of the series |
sonarr_series_title | Title of the series |
sonarr_series_path | Full path to the series |
sonarr_series_tvdbid | TVDB ID for the series |
sonarr_series_tvmazeid | TVMaze ID for the series |
sonarr_series_imdbid | IMDB ID for the series |
sonarr_series_type | Type of the series, Anime, Daily or Standard |
sonarr_episodefile_id | Internal ID of the episode file |
sonarr_episodefile_relativepath | Path to the episode file relative to the series' path |
sonarr_episodefile_path | Full path to the episode file |
sonarr_episodefile_episodecount | Number of episodes in the episode file |
sonarr_episodefile_seasonnumber | Season number of episode file |
sonarr_episodefile_episodenumbers | Comma separated list of episode numbers |
sonarr_episodefile_episodeairdates | Air date from original network |
sonarr_episodefile_episodeairdatesutc | Air Date with Time in UTC |
sonarr_episodefile_episodetitles | Pipe (| ) separated list of episode titles |
sonarr_episodefile_quality | Quality name from Sonarr |
sonarr_episodefile_qualityversion | 1 is the default, 2 for proper, 3+ could be used for anime versions |
sonarr_episodefile_releasegroup | Release group, will not be set if it is unknown |
sonarr_episodefile_scenename | Original release name |
sonarr_episodefile_sourcepath | Full path to the episode file that was imported |
sonarr_episodefile_sourcefolder | Full path to the folder the episode file was imported from |
sonarr_deletedrelativepaths | Pipe (| ) separated list of files that were deleted to import this file |
sonarr_deletedpaths | Pipe (| ) separated list of full paths for files that were deleted to import this file |
sonarr_download_id | The hash of the torrent/NZB file downloaded (used to uniquely identify the download in the download client) |
On Rename
Environment Variable | Details |
---|---|
sonarr_eventtype | Rename |
sonarr_series_id | Internal ID of the series |
sonarr_series_title | Title of the series |
sonarr_series_path | Full path to the series |
sonarr_series_tvdbid | TVDB ID for the series |
On Test
When adding the script to Sonarr and run 'Test' the script will be invoked with the following parameters. The script should be able to gracefully ignore any other eventtype
Environment Variable | Details |
---|---|
sonarr_eventtype | Test |
Arguments
(Warning: Adding arguments is no longer supported in Sonarr v3, point to the script directly.)
Additional command line line arguments that are passed to your script, such as running your script through cmd.exe you would set the path to cmd.exe
and the arguments to /c C:\Path\to\script.bat
.
Specific usage tips
PHP
The information from Sonarr will not be added to $_ENV as one might expect but should be included in the $_SERVER variable. A sample script to use this information to convert a file can be found here.
PowerShell
Sample script using the Sonarr environment variables to create EDL files for all episodes is here.
Reverse Symlinking
For those moving from Medusa [this seems to work well] (https://github.com/Sonarr/Sonarr/wiki/Reverse-symlink-script-for-Connect)
Getting Started
Troubleshooting
- Asking for Help
- Logging and Log Files
- AppData Directory
- Searches Indexers and Trackers
- Downloads and Importing
- Recovering from a Failed Update
Additional Configuration
More Information
- Completed Download Handling
- Failed Download Handling
- Indexer Integration
- Backup and Restore
- PushOver
- Sorting and Renaming
- Anime naming scheme
- Monitoring Series and Episodes
- RSS Sync
- Indexer Seed Ratio
Development