9 Custom Post Processing Scripts
Doug Krahmer edited this page 2020-10-13 10:00:48 -07:00

If you're looking to trigger a custom script in your download client to tell Lidarr when to update, you can find more details here. Scripts are added to Lidarr via the Connect Settings page.

Overview

Lidarr can execute a custom script when new albums are imported or a artist is renamed, depending on the which action occurred the parameters will be different. Parameters are passed to the script through environment variables (allowing for more flexibility in what we send to the script and not having to worry about a particular order).

Environment Variables

On Grab
Environment Variable Details
lidarr_eventtype Grab
lidarr_artist_id Internal ID of the artist
lidarr_artist_name Name of the artist
lidarr_artist_mbid MusicBrainz ID for the artist
lidarr_artist_type Type of the artist, Person, Group, etc
lidarr_release_albumcount Number of albums in the release
lidarr_release_albumreleasedates Release Date from original label
lidarr_release_albumtitles Pipe (|) separated list of album titles
lidarr_release_title NZB/Torrent title
lidarr_release_indexer Indexer where the release was grabbed
lidarr_release_size Size of the release reported by the indexer
lidarr_release_quality Quality name from Lidarr
lidarr_release_qualityversion 1 is the default, 2 for proper
lidarr_release_releasegroup Release Group, will not be set if it is unknown
lidarr_download_client The client the torrent/NZB was passed to
lidarr_download_id The hash of the torrent/NZB file downloaded (used to uniquely identify the download in the download client)
On Track Download/On Upgrade
Environment Variable Details
lidarr_eventtype Download
lidarr_isupgrade True when an an existing file is upgraded, otherwise False
lidarr_artist_id Internal ID of the artist
lidarr_artist_name Name of the artist
lidarr_artist_path Full path to the artist
lidarr_artist_mbid MusicBrainz ID for the artist
lidarr_artist_type Type of the artist, Person, Group, etc.
lidarr_album_id Internal ID of the album
lidarr_album_title Title of the downloaded album
lidarr_album_mbid MusicBrainz ID for the album
lidarr_album_releasedate Album release date
lidarr_trackfile_id Internal ID of the track file
lidarr_trackfile_relativepath Path to the track file relative to the artist' path
lidarr_trackfile_path Full path to the track file
lidarr_trackfile_trackcount Number of tracks in the track file
lidarr_trackfile_tracknumbers Comma separated list of track numbers
lidarr_trackfile_trackreleasedates Release date from original Album
lidarr_trackfile_tracktitles Pipe (|) separated list of track titles
lidarr_trackfile_quality Quality name from Lidarr
lidarr_trackfile_qualityversion 1 is the default, 2 for proper
lidarr_trackfile_releasegroup Release group, will not be set if it is unknown
lidarr_trackfile_scenename Original release name
lidarr_trackfile_sourcepath Full path to the track file that was imported
lidarr_trackfile_sourcefolder Full path to the folder the track file was imported from
lidarr_deletedrelativepaths Pipe (|) separated list of files that were deleted to import this file
lidarr_deletedpaths Pipe (|) separated list of full paths for files that were deleted to import this file
lidarr_download_client The client the torrent/NZB was passed to
lidarr_download_id The hash of the torrent/NZB file downloaded (used to uniquely identify the download in the download client)
On Album Download
Environment Variable Details
lidarr_eventtype AlbumDownload
lidarr_artist_id Internal ID of the artist
lidarr_artist_name Name of the artist
lidarr_artist_path Full path to the artist
lidarr_artist_mbid MusicBrainz ID for the artist
lidarr_artist_type Type of the artist, Person, Group, etc.
lidarr_album_id Internal ID of the album
lidarr_album_title Title of the downloaded album
lidarr_album_mbid MusicBrainz ID for the album
lidarr_album_releasedate Album release date
lidarr_addedrelativepaths Pipe (|) separated list of files that were added to import this file
lidarr_addedpaths Pipe (|) separated list of full paths for files that were added to import this file
lidarr_deletedrelativepaths Pipe (|) separated list of files that were deleted to import this file
lidarr_deletedpaths Pipe (|) separated list of full paths for files that were deleted to import this file
lidarr_download_client The client the torrent/NZB was passed to
lidarr_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
lidarr_eventtype Rename
lidarr_artist_id Internal ID of the artist
lidarr_artist_name Name of the artist
lidarr_artist_path Full path to the artist
lidarr_artist_mbid MusicBrainz ID for the artist
lidarr_artist_type Type of Artist (Person, Group, etc.)

Arguments

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 Lidarr 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 Lidarr environment variables to create EDL files for all albumss is here.

Beets

An example script to trigger beets is here. You need to have your beets config file setup correctly. An example is here.

Key points:

  • This will not work on Lidarr 0.5.0.583. It requires nightly or a 0.6.0 build.
  • directory must be your (only) root directory in Lidarr
  • import\copy must be no to prevent beets moving files
  • You should configure beets file naming to match your lidarr file naming to avoid nasty surprises
  • You must set BEET_CONFIG to point to your beets config file in beet_import.sh
  • You should trigger the custom script on Album Import.

AHK

To use the environment variables in AHK you can use the EnvGet command, Here are some examples: EnvGet, EventType, lidarr_eventtype EnvGet, MusicFolder, lidarr_artist_path