Post processing arguments help

I can’t figure out how to pass arguments to a custom post processing script. Right now it just consists of:

#!/bin/bash
env > /tmp/env_var.txt

It shows a few variables without adding arguments but I need EpisodeFile_Path. Do I add “EpisodeFile_Path” to the arguments in the UI or what? I can’t seem to get it to work.

Sonarr sets environment variables in the script when it calls the script (after importing the file) you don’t need to pass arguments to your script.

Ok, I got that now but almost all my variables are blank:

#!/bin/bash

env > /tmp/env_var.txt
echo "$sonarr_release_releasegroup" >> /tmp/test.txt
echo "$sonarr_episodefile_id" >> /tmp/test.txt
echo "$sonarr_episodefile_relativepath" >> /tmp/test.txt
echo "$sonarr_episodefile_path" >> /tmp/test.txt
echo "$sonarr_episodefile_episodecount" >> /tmp/test.txt
echo "$sonarr_episodefile_seasonnumber" >> /tmp/test.txt
echo "$sonarr_episodefile_episodenumbers" >> /tmp/test.txt
echo "$sonarr_episodefile_episodeairdates" >> /tmp/test.txt
echo "$sonarr_episodefile_episodeairdatesutc" >> /tmp/test.txt
echo "$sonarr_episodefile_episodetitles" >> /tmp/test.txt
echo "$sonarr_episodefile_quality" >> /tmp/test.txt
echo "$sonarr_episodefile_qualityversion" >> /tmp/test.txt
echo "$sonarr_episodefile_releasegroup" >> /tmp/test.txt
echo "$sonarr_episodefile_scenename" >> /tmp/test.txt
echo "$sonarr_episodefile_sourcepath" >> /tmp/test.txt
echo "$sonarr_episodefile_sourcefolder" >> /tmp/test.txt
echo "$sonarr_episodefile_path" >> /tmp/test.txt

Just shows a lot of blank. The release group is the only thing that shows. My env_var.txt also only shows a handful of Sonarr variables. Should it be showing more?

sonarr_release_title=Regular.Show.S08E22.HDTV.x264-W4F[rartv]
sonarr_series_type=Standard
sonarr_release_releasegroup=W4F
HOSTNAME=c9445fb5a1d6
PUID=99
TERM=xterm
sonarr_series_id=133
sonarr_release_size=79106000
sonarr_release_episodecount=1
PGID=100
sonarr_eventtype=Grab
sonarr_release_seasonnumber=8
HOST_OS=unRAID
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
sonarr_release_indexer=Rarbg
sonarr_series_title=Regular Show
PWD=/opt/NzbDrone
TZ=America/Denver
sonarr_release_episodenumbers=22
sonarr_series_tvdbid=188401
SHLVL=1
HOME=/root
XDG_CONFIG_HOME=/config/xdg
_=/usr/bin/env

It only seems to be triggering on grab.

On Download/On Upgrade only trigger when the file is imported by Sonarr after the episode finishes downloading (On Upgrade when it’s an upgrade for an existing file).

Right, but it’s not doing that. I do a manual search in Sonarr to test. I pick a small file to speed things up, it gets sent to the torrent program, downloads, imports, and removed from the Sonarr queue. Then I check the file and it’s blank for any “on download/upgrade” variable. It shows the event type as “grab”.

Never mind. Once it was sent to the torrent program, it would finish downloading before it ever even got to the queue in Sonarr. So it never got imported. I’ve had that issue before but only with small test files.

Is your client removing items automatically? It doesn’t matter if the download finishes before Sonarr sees it in the client as long as it stays in the client.

Yes, actually. I have a clean up script that checks via the Sonarr API if the item is gone from the queue and removes it. This normally isn’t an issue but when I use a small test file of 50-75mb the download may finish before the item gets in the queue. I’ll have to fix that somehow but I’m not sure how and it works in practice as I never actually download something that small.

Sonarr will remove a completed torrent as long as it has stopped seeding, so having your script/settings stop the torrent but not remove it should cover all cases.

I thought that only worked for some torrent clients.

If you use the Torrent Blackhole, sure? Otherwise:

If the “Completed Download Handling - Remove” option is enabled in Sonarr’s settings, Sonarr will delete the original file and torrent from your client, but only if the client reports that seeding is complete and torrent is stopped.

When trying to configure rtorrent:

“Sonarr is unable to remove torrents that have finished seeding when using rTorrent”

But I have since switched to qbittorrent and I thought it was the same case but I guess not. That’s why I set it up that way to begin with instead of letting Sonarr do it but I guess I can but it back now. Thanks for pointing that out.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.