Sonarr version: 2.0.0.5322
Mono version : 5.18.1.0
OS: Ubuntu 16.04 LTS
Debug logs: TBD
Description of issue: I read all of the other posts that I could find, but I did not find a solution to my problem. I have Sonarr connection calling a custom script on download and rename:
It runs when it is supposed to and completes without errors, but I have yet to find the correct destination syntax. Currently it will copy the correct file from /media/tv1/series/season/episodefile to the backup drive /media/tv1bu/, but I need a way to include the rest of the directory path for the series/season/ on the destination. I can’t find an environment variable that is only the relative directory path. I can’t pass the full path on to the destination since the drive path changes, and existing variables all seem to be full path. Relative path might work if it was only the directory, but it appears to include the full filename. I know I’m probably overlooking something simple, but this is the first step in a two part process where I have to add tags to specify which series are on what drive since there are multiple drives like /media/tv1, /media/tv2/, etc. I’m used to sql script using select, or update/replace/where as needed, so bash script syntax is new to me.
The environment variable Sonarr_EpisodeFile_RelativePath is included, but that’s relative to the series folder, not the the root folder. Substituting the path directly in your script may be easiest since there isn’t a relative path from the root folder returned.
In v3 you’d be able to get root folder path for the series from the the API, but that would still be more work.
Because the destination drive path is different for the backup, I can’t figure out how to substitute just the series/season portion of the path to the specified destination drive each time it is run. Like I said, it will copy the correct file to the specified destination drive path, but then I have to manually move the file to the correct subfolder for the series/season manually.
Correct me if I’m wrong, but you want to replace /media/tv1/ with /media/tv1bu/, leaving the rest of the path the same. I don’t know what the equivalent in bash is, but a string substitution would do it, for example in C# I’d do sonarr_episodefile_path.Replace("/media/tv1/", "/media/tv1bu/") or use regex to avoid having to write a line for each drive.
You are correct, and that helps. I was researching string substitution in bash when you replied, but I was headed down the wrong road with delimiting the /. As a side note, I planned to use a for loop when the time comes to map the tags, but I noticed none of the listed environment variables on github show to be for the tag. Is this coming, or something there is another way to filter by tags?
If tags are specified in the Custom Script settings then only series with one or more matching tags will trigger than script, they are not sent to the script.
Yes, and I have added tags representing the drive paths the series were stored on in order to execute a different script for each of the four drives, but was wondering out loud if there might be a different way to do it via a single script if I could parse the tag. I didn’t mean to digress, and I appreciate the help. You always do a great job responding to people even when it is not regarding something broken, and it is appreciated. I will continue with the string replacement and and separate script execution. Thanks again…
If you do a simple string replace you could do it once for each of the drives in a single script, it should only alter the path if it’s actually changed or check if path starts with X then replace then else if Y then do something else, etc or finally if they’re tv1, tv2, tv3 and tv4 you could probably use regex to replace tv# with tv#bu.