Sonarr not respecting NZBGet script file rename

I have a very annoying issue that’s been pestering me for over a year now but I think I finally pinpointed the source. I have 2 custom nzbget scripts that rename a file based on some parameters. The first works fine always but the second doesn’t. It works when no category is selected and so sonarr doesn’t touch it so it’s an issue with Sonarr. The issue is that Sonar takes a file that has been renamed by the script and gives it the original name before the last rename script.

Here is a sample from activity tab:

Name:
test-Obfuscated
Source:
/mnt/downloads/nzbget/series/test-Obfuscated/test.avi
Imported To:
/mnt/series/test/Season 1/test-Obfuscated.avi

I have renaming option disabled. Where is Sonarr getting this name from? I would have assumed that the filename should never change unless rename option is enabled. Is it perhaps a timing issue? It doesn’t seem to happen every time though can’t say that for sure.

It depends on the file name. Sonarr will use the filename unless it’s not likely to be a scene name (best guess, but has to include at least one . in the name, otherwise it will use the folder name.

It is definitely a scene name with plenty of dots though that’s only after the first rename script as original file name is obfuscated. It really need to be an option as it’s extremely frustrating when it’s doing something without your knowledge or even a way to disable it. This is making nzbget scripts useless, it a script renames and then sonarr reverses it back, that’s crazy. I also never saw sonarr use folder name even when the file name is obfuscated.

It looks like Sonarr prefers the release name (from the download client) when that name is parsable and not a full season release (which is typically the same as the folder name) and it’s purpose is to rename obfuscated filenames.

So how do I disable this? Right now it is impossible to remove and use sonarr import -Obfuscated from the file which is really annoying.

If you enable renaming and use {Original Filename} as the renaming token that will force Sonarr to use the filename and it won’t fallback to the folder name.

If that doesn’t solve things for you, you should also be able to rename the folder in your script?

Will try that. How should the other fields be configured? Since I do not want any renaming at all how should other fields be set like Season etc…?

That’s what I actually am trying to do now, though having problems with sonarr using a different name and failing to import. I manually changed NZBPP_DIRECTORY environmental variable to the new value but sonarr is using some other name that’s slightly different but can’t tell where it’s getting it from. What other environmental variable might sonarr be using?

You could try changing both DIRECTORY and FINALDIR, but it’s not something I’ve experimented with. See https://github.com/nzbget/nzbget/wiki/Post-processing-scripts#control-commands

But I’d try using {Original Filename} first.

I’ve spent time on the script now so will try to get it to work. It would still be useful for non-sonarr downloads. Will try that after I get this working, can’t troubleshoot with renaming enabled in sonarr…

You could also use a post-processing script in Sonarr… That would have access to the “full path to the episode file that was imported”, for example.

After discussing this on NZBGet forums and testing it is clear that Sonarr is not using folder/directory name. It is in fact using NZBNAME environmental variable from NZBGet. Renaming the directory breaks Sonarr import but with a special echo/print in NZBGet script the directory can be updated. This works in that Sonarr can now find the path but it does not use directory name to rename files so it’s of no real use. NZBNAME variable cannot be changed in NZBGet Post-processing script.

Also The tool tip next to Rename episodes is wrong and misleading. It clearly states that if disabled the original filename will be used when in fact it wont be.

Right, there are some checks to make sure the filename is valid and it uses the NZB name when it makes sense to avoid importing obfuscated or ugly filenames.

If you want to forcibly use the filename, use {Original Filename} that will ignore everything and use the filename regardless of it’s formatting.

The tooltip is a bit confusing in this case, but probably less confusing to most users than will use the release name or filename.

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