From 289b042f47b16571ce4461d040911015c59303c4 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 21 Jul 2015 09:45:50 -0700 Subject: [PATCH] Custom scripts --- Custom-Post-Processing-Scripts.md | 51 +++++++++++++++++++------------ Manually-Triggering-Imports.md | 27 ++++++++++++++++ 2 files changed, 58 insertions(+), 20 deletions(-) create mode 100644 Manually-Triggering-Imports.md diff --git a/Custom-Post-Processing-Scripts.md b/Custom-Post-Processing-Scripts.md index 1ae9006..9be1608 100644 --- a/Custom-Post-Processing-Scripts.md +++ b/Custom-Post-Processing-Scripts.md @@ -1,27 +1,38 @@ -**WARNING** Only follow these instructions if you understand the risks of doing so and know how to write and enable a post processing script in your download client +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: -## Disable Drone Factory Folder Scanning ## +### Overview ### -You can disable Drone Factory folder scanning via the advanced setting "Drone Factory Interval" on the download client settings page, by setting it to zero. +Sonarr can execute a custom script when new episodes are imported or a series 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). In all cases the Environment Variables Sonarr sends will be prefixed with `Sonarr` so, the `EventType` Sonarr sends would be `Sonarr.EventType`. -## Post Processing Script ## +### Environment Variables ### -You can configure your download client to run a script to send a command to Sonarr's API instructing it to run a scan on the Drone Factory folder. +##### On Download/On Upgrade ##### -The script will need to send a POST with a JSON body as described here: [Command](Command#downloadedepisodesscancommand) +| Environment Variable | Details | +|---|---| +| EventType | Download | +| Series.Id | Internal ID of the series | +| Series.Title | Title of the series | +| Series.Path | Full path to the series | +| Series.TvdbId | TVDB ID for the series | +| EpisodeFile.Id | Internal ID of the episode file | +| EpisodeFile.RelativePath | Path to the episode file relative to the series' path | +| EpisodeFile.Path | Full path to the episode file | +| EpisodeFile.SeasonNumber | Season number of episode | +| EpisodeFile.EpisodeNumbers | Comma separated list of episode numbers | +| EpisodeFile.EpisodeAirDates | Air date from original network | +| EpisodeFile.EpisodeAirDatesUtc | Air Date with Time in UTC | +| EpisodeFile.Quality | Quality name from Sonarr | +| EpisodeFile.QualityVersion | 1 is the default, 2 for proper, 3+ could be used for anime versions | +| EpisodeFile.ReleaseGroup | Release group, will not be set if it is unknown | +| EpisodeFile.SceneName | Original release name | -## Example Scripts ## +##### On Rename ##### -#### curl #### -```` -curl http://localhost:8989/api/command -X POST -d '{"name": "downloadedepisodesscan"}' --header "X-Api-Key:YOUR_API_KEY_GOES_HERE" -```` - -#### PowerShell #### -```` -$url = "http://8989/api/command" -$json = "{ ""name"": ""downloadedepisodesscan"" }" - -Write-Host "Publishing update $version ($branch) to: $url" -Invoke-RestMethod -Uri $url -Method Post -Body $json -Headers @{"X-Api-Key"="YOUR_API_KEY_GOES_HERE"} -```` +| Environment Variable | Details | +|---|---| +| EventType | Rename | +| Series.Id | Internal ID of the series | +| Series.Title | Title of the series | +| Series.Path | Full path to the series | +| Series.TvdbId | TVDB ID for the series | \ No newline at end of file diff --git a/Manually-Triggering-Imports.md b/Manually-Triggering-Imports.md new file mode 100644 index 0000000..ad12ef1 --- /dev/null +++ b/Manually-Triggering-Imports.md @@ -0,0 +1,27 @@ +**WARNING** Only follow these instructions if you understand the risks of doing so and know how to write and enable a post processing script in your download client [[Manually-Triggering-Imports]] + +## Disable Drone Factory Folder Scanning ## + +You can disable Drone Factory folder scanning via the advanced setting "Drone Factory Interval" on the download client settings page, by setting it to zero. + +## Post Processing Script ## + +You can configure your download client to run a script to send a command to Sonarr's API instructing it to run a scan on the Drone Factory folder. + +The script will need to send a POST with a JSON body as described here: [Command](Command#downloadedepisodesscancommand) + +## Example Scripts ## + +#### curl #### +```` +curl http://localhost:8989/api/command -X POST -d '{"name": "downloadedepisodesscan"}' --header "X-Api-Key:YOUR_API_KEY_GOES_HERE" +```` + +#### PowerShell #### +```` +$url = "http://8989/api/command" +$json = "{ ""name"": ""downloadedepisodesscan"" }" + +Write-Host "Publishing update $version ($branch) to: $url" +Invoke-RestMethod -Uri $url -Method Post -Body $json -Headers @{"X-Api-Key"="YOUR_API_KEY_GOES_HERE"} +````