In which order does Sonarr run custom scripts?

Sonarr version
Mono version (if Sonarr is not running on Windows):
OS: Windows 10 (21H2):
Debug logs:
Description of issue:

I am trying to make a python custom script that extracts the subtitles from a video on import. I am a bit confused about the order of things.

I tried to process all files in sonarr_episodefile_sourcefolder with FFmpeg, however, it does not seem like files in this folder can be processed. Nothing happens. Perhaps because Sonarr moves the files before triggering the custom script? I am not sure.

Should I use the sonarr_episodefile_sourcefolder environment variable, or am I on the wrong track.

From the linked wiki

“Sonarr can execute a custom script when an episode is newly imported or renamed.”

From On Import Trigger
" sonarr_episodefile_sourcefolder Full path to the folder the episode file was imported from"

Seems to infer that it is triggered by the Import, not prior to it. Therefore the from path will be empty. You will likely need below instead, since that will be where the file is now.

" sonarr_episodefile_sourcepath Full path to the imported episode file"

Depending on what you’re trying to do and the desired end result, you may also want to look into post-processing in your download client instead.

Thanks @fanboy

I actually did run the script in Sabnzbd, but…

I am getting content from both Sab and Qbit. Qbit does not have a post-process option, so I figured I would try Sonarr and Radarr custom script instead.

My download clients download to a fast M.2 drive. When these files are imported they are moved by *arr to a slow drive. Naturally, I don’t want to process the files on the slow drive, because that takes longer. So I need a way to trigger the script before importing. But it seems there is no way to do that currently.

I guess I will just have to make *arr apps import to the fast drive, but it’s not ideal because that drive has limited storage.