How to post-process Radarr files after import with custom script? How can Container A talk to Container B?

Running FileBot from the console, Groovy / FileBot scripting, shell scripts, etc
Post Reply
janaxhell
Posts: 7
Joined: 06 Aug 2022, 15:59

How to post-process Radarr files after import with custom script? How can Container A talk to Container B?

Post by janaxhell »

Hello, I'm not new to Filebot for Windows, but I'm totally new to Filebot for Docker.
Since I don't like the way Radarr renames files, I'd like to do that with FIlebot.
I know this is a Radarr question, but i hope I'll find here someone using both.
I have deployed filebot-node (not sure it's the right flavour) and created this script:

Code: Select all

#!/bin/bash
filebot -rename --db TheMovieDB --lang it --conflict override --format "{n.colon(' - ')} ({vs}-{vf}-{ac}) ({y}) [{ audioLanguages.ISO3.join('+').upper() }]"
I have saved it as rename_ita.sh, chmod u+x and tested filebot ok from its own console via Portainer with one of the amc scripts that I found here, the one that creates a .tsv list of available files.
I have tried to Connect a Custom Script from Radarr, but when I test it, it fails with "Script exited with code: 127"
As far as I could understand googling, that means Radarr cannot see the command "filebot" in the script, so how do I make it see it?
I have both Radarr and Filebot pointing at /data2 folder AND the relative one where movie library is stored, /data2/media/movies.

Side note: I prefer to keep all my containers config files in /config/[container name], but Filebot seems to be using /data as config folder, which overlaps with the folder that I mount for storage that every other container uses, so I mounted /config/filebot:/data and /path-to-files/data:/data2
User avatar
rednoah
The Source
Posts: 21338
Joined: 16 Nov 2011, 08:59

Re: How to post-process Radarr files after import with custom script?

Post by rednoah »

Conceptually, each container is a separate machine, so one container cannot execute commands on another just like one machine cannot execute commands on another, unless you set up a network connection of some kind, e.g. have the first machine log into the second machine via SSH to run commands, or have the second machine accept HTTP requests and then run some command in response, etc.


:arrow: I'd have the Radarr container move completed files to some specific folder, and then have the FileBot folder process all the files in that specific folder once a day on a schedule. That's they only easy solution if each application is running in it's own container.
:idea: Please read the FAQ and How to Request Help.
janaxhell
Posts: 7
Joined: 06 Aug 2022, 15:59

Re: How to post-process Radarr files after import with custom script? How can Container A talk to Container B?

Post by janaxhell »

Ok. But there are cases in which I can call bash scripts from a container, I use this https://github.com/TheCaptain989/lidarr-flac2mp3 with Lidarr and it works.
Is there any chance to "pair" filebot as a variable to Radarr the same way this one does? As far as I understand the variable DOCKER_MODS=thecaptain989/lidarr-flac2mp3:latest makes Lidarr "aware" of the script so that when it's called, it knows it exists and fires it (although it's not a container, just a script in a folder). The only change I had to make in Lidarr was to add that variable to the container and set the path in Custom Script settings.
User avatar
rednoah
The Source
Posts: 21338
Joined: 16 Nov 2011, 08:59

Re: How to post-process Radarr files after import with custom script? How can Container A talk to Container B?

Post by rednoah »

You can of course build your own container that includes all the tools you need in one single container. So that's what DOCKER_MODS does internally one way or another, but that's specific to and only works for the Linuxserver.io Containers. If you use a container not based on the Linuxserver.io Containers base image, then adding the DOCKER_MODS environment variable will do nothing.
:idea: Please read the FAQ and How to Request Help.
janaxhell
Posts: 7
Joined: 06 Aug 2022, 15:59

Re: How to post-process Radarr files after import with custom script? How can Container A talk to Container B?

Post by janaxhell »

All right, thanks. Then I'm out of luck, adapting a container is way beyond my ability, I'm a beginner with these.
I don't think I'll use the watch-folder workaround, because I have different presets based on movie languages, so a blind scan of everything would lead to the same preset applied to everything. Not to say the mess of having all movies together AND unrecognized movies. Too bad such popular apps haven't taken advantage of native interoperability, like i.e. API.
Automation-wise, *arrs+Filebot would be a killer combo.
I'll keep using it manually.
User avatar
rednoah
The Source
Posts: 21338
Joined: 16 Nov 2011, 08:59

Re: How to post-process Radarr files after import with custom script? How can Container A talk to Container B?

Post by rednoah »

janaxhell wrote: 07 Aug 2022, 11:40 Then I'm out of luck, adapting a container is way beyond my ability, I'm a beginner with these.
Indeed, containers make some tasks easier (i.e. deployment of pre-configured machines) but also make other tasks difficult or impossible, i.e. no container interoperability by design, just doesn't work unless the containerised is already by nature a web application.

janaxhell wrote: 07 Aug 2022, 11:40 I don't think I'll use the watch-folder workaround, because I have different presets based on movie languages, so a blind scan of everything would lead to the same preset applied to everything.
Do you not have the same problem when *arrs is calling FileBot? You would necessarily have to have some kind of way of knowing which files are completed / processed, know which files need to be processed with which naming scheme, i.e. easily achieved by having separate folders. *arrs by itself knows only download status, no?

As for custom naming on the FileBot side of things, your custom format can be smart enough to do different things for different files. Alternatively, you can just process different files with different commands.
:idea: Please read the FAQ and How to Request Help.
janaxhell
Posts: 7
Joined: 06 Aug 2022, 15:59

Re: How to post-process Radarr files after import with custom script? How can Container A talk to Container B?

Post by janaxhell »

rednoah wrote: 07 Aug 2022, 14:24 Do you not have the same problem when *arrs is calling FileBot? You would necessarily have to have some kind of way of knowing which files are completed / processed, know which files need to be processed with which naming scheme, i.e. easily achieved by having separate folders. *arrs by itself knows only download status, no?
You can tag files so that a certain script fires only with selected tags, so if I tag a movie with "italian" and set this tag to the (filebot) script configured for italian language, only those files will be processed. I would have several clone scripts that activate only when their language tag is found in new downloads.
rednoah wrote: 07 Aug 2022, 14:24 As for custom naming on the FileBot side of things, your custom format can be smart enough to do different things for different files. Alternatively, you can just process different files with different commands.
Thanks, I'll check that, will be useful for manual renaming as well.
User avatar
rednoah
The Source
Posts: 21338
Joined: 16 Nov 2011, 08:59

Re: How to post-process Radarr files after import with custom script? How can Container A talk to Container B?

Post by rednoah »

Well, presumably *arrs have the ability to move completed downloads into separate destination folders per user-defined tag. If that works, then the rest is straight-forward.
:idea: Please read the FAQ and How to Request Help.
janaxhell
Posts: 7
Joined: 06 Aug 2022, 15:59

Re: How to post-process Radarr files after import with custom script? How can Container A talk to Container B?

Post by janaxhell »

No, the chain would be this:

- Radarr finds a movie on RSS
- movie has "italian" tag (because I have set it so, I know it exists in italian)
- client downloads movie
- when complete, Radarr imports movie to Library title-folder (i.e /movies/Matrix (1999)/Matrix (1999) (1080p DTS) [IT] [EN].mkv
- all scripts that are set to act "On import" do their checks, if false, they do nothing
- those that check something as true do their job, in this case Matrix = "italian"
- all the scripts that have the "italian" tag set will do what they should to imported movies, in this case Filebot would rename Matrix.

So the action happens after files are imported to final folder. But this is theory, I cannot try, I'm supposing this because flac2mp3 works this way on Lidarr, it fires only for albums with a certain tag.
And because in Custom Scripts section all *arrs say "Applies to (movies/series/albums) with at least one matching tag".
When Radarr imports files, it doesn't care what you do to them afterwards, its job is finished, so you can rename files inside title-folders in place, no need to move to other folders.
User avatar
rednoah
The Source
Posts: 21338
Joined: 16 Nov 2011, 08:59

Re: How to post-process Radarr files after import with custom script? How can Container A talk to Container B?

Post by rednoah »

janaxhell wrote: 07 Aug 2022, 18:14 - when complete, Radarr imports movie to Library title-folder (i.e /movies/Matrix (1999)/Matrix (1999) (1080p DTS) [IT] [EN].mkv
Why not configure Radarr to preserve your custom tag somewhere in the file path? I don't use Radarr so I don't know if this is supported or not.

e.g. via folder:

Code: Select all

/radarr/italian/movies/Matrix (1999)/Matrix (1999) (1080p DTS) [IT] [EN].mkv
e.g. via file name:

Code: Select all

/movies/Matrix (1999)/Matrix (1999) (1080p DTS) [IT] [EN] [italian].mkv

:idea: Alternatively, the [IT] seems to identify italian tagged movies. If your files are consistent, then you can select and process files based on the language of the first audio stream?


:idea: Alternatively, you could have your custom bash script that is running inside the *arrs container mark the completed files somehow, e.g. set xattr to the tag value, set Last-Modified to some magic date/time value, write tag value to a text file, write file path to a different "todo list" text file for each tag, etc.
:idea: Please read the FAQ and How to Request Help.
janaxhell
Posts: 7
Joined: 06 Aug 2022, 15:59

Re: How to post-process Radarr files after import with custom script? How can Container A talk to Container B?

Post by janaxhell »

Maybe, but since I cannot make Radarr see Filebot, it's no use, what can I do?

About /italian path, no, it's much more complex than that: movies produced in Italy, released dubbed in Italy, released not dubbed, movies that I already have not dubbed HD and I'm looking for a dubbed version SD to mux audio and so on, multiplied for several languages. The "italian" tag assigned to script would just hit the right stuff. I sort movies by genre folders, no matter the language, an additional /italian path would be overly complicated.
User avatar
rednoah
The Source
Posts: 21338
Joined: 16 Nov 2011, 08:59

Re: How to post-process Radarr files after import with custom script? How can Container A talk to Container B?

Post by rednoah »

janaxhell wrote: 07 Aug 2022, 18:55 Maybe, but since I cannot make Radarr see Filebot, it's no use, what can I do?
Well, there's lots of things you can do:
rednoah wrote: 07 Aug 2022, 18:36 Alternatively, you could have your custom bash script that is running inside the *arrs container mark the completed files somehow, e.g. set xattr to the tag value, set Last-Modified to some magic date/time value, write tag value to a text file, write file path to a different "todo list" text file for each tag, etc.

e.g. presumably, you already have a custom script that is called by *arrs in the *arrs container somehow, so you could create a new hardlink (i.e. have the same file twice in different folders) in another folder there:

Code: Select all

#!/bin/sh -x
TAG="ITA" // one script per tag assuming that *arrs doesn't pass that piece of information along somehow
FILE="$1" // assuming that *arrs passes the input file as first positional argument
FILENAME=$(basename "$FILE")

ln "$1" "/data2/todo/$TAG/$FILENAME"
1. Create an additional hardlink in your *arrs custom script (i.e. let *arrs have it's own file structure that you never touch, and have your own file structure that you deal with however you please)
2. Use FileBot (GUI or CLI both fine) to move files from the todo/$TAG into their final destination



:idea: I would recommend this approach because the *arrs developers will definitely tell to never move / rename files that are under *arrs management, and the todo/$TAG folders approach (in combination with some final output folder where you move / rename files into) will make keeping track of things dead simple.
:idea: Please read the FAQ and How to Request Help.
janaxhell
Posts: 7
Joined: 06 Aug 2022, 15:59

Re: How to post-process Radarr files after import with custom script? How can Container A talk to Container B?

Post by janaxhell »

Thanks, I will study this, but I'm not a script expert, I understand only a little of what you say. I have no problem moving files, Radarr library is just a temp "hangar", as soon as movies are ready, I move them to an external HDD. My server has limited space, so it's basically just a robot that gets stuff for me and I take it out when available.
Post Reply