Combine FileBot and JDownloader (both as Docker-Container)

Support for unRAID and docker container users
Post Reply
updatefreak
Posts: 10
Joined: 03 Aug 2023, 21:16

Combine FileBot and JDownloader (both as Docker-Container)

Post by updatefreak »

Hello,

I have JDownloader as Docker-Container and would like to add also FileBot for automatism:
Download finished -> Extract archives (contain several parts) -> rename mkv-files and srt-files -> move to tv-shows or movie-folder or unsorted-Folder -> clean up and remove archives

Therefore I want to ask if these steps are working:
1. Deactivate automatic extraction at jdownloader (as this will be done by script)
2. add event scripter in jdownloader and add the following code

Code: Select all

[ {
"eventTrigger" : "ON_PACKAGE_FINISHED",
"enabled" : true,
"name" : "Execute FileBot (PackageFinished)",
"script" : "var script = '/volume1/docker/jdownloader2/scripts/jdownloader-postprocess.sh'\n\nvar path = package.getDownloadFolder()\nvar name = package.getName()\nvar label = package.getComment() ? package.getComment() : 'N/A'\n\nvar command = [script, path, name, label, 'PACKAGE_FINISHED']\n\nlog(command)\nlog(callSync(command))\n",
"eventTriggerSettings" : {
}
} ]
3. jdownloader-postprocess.sh save to /volume1/docker/jdownloader2/scripts/jdownloader-postprocess.sh with the following content:

Code: Select all

#!/bin/sh
SERIEN="/volume1/Videos/Serien/{n}/Staffel {s}/{n} - {s00e00} - {t}"
FILME="/volume1/Videos/Filme/{n} ({y})"
UNSORTIERT="/path/{file.structurePathTail}"


docker exec FileBot /opt/filebot/filebot.sh -script fn:amc --lang de --log-file amc.log --action move "$1" --def "seriesFormat=$SERIEN" "movieFormat=$FILME" "unsortedFormat=$UNSORTIERT" -non-strict --conflict skip --def movieDB=TheMovieDB seriesDB=TheTVDB --def unsorted=y --def skipExtract=n --def clean=y
## Aufräumen, --def root löscht den Unterordner mit
docker exec FileBot /opt/filebot/filebot.sh -script fn:cleaner "$1" --def root=y

Questions
  • Should I use FileBot oder FileBot Watcher as Docker-Container?
  • How to handle subtitle files in that script? How to get them in the format "Film (2020).Deutsch.srt" or "Film (2020).Englisch.Forced.srt"
User avatar
rednoah
The Source
Posts: 22854
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Combine FileBot and JDownloader (both as Docker-Container)

Post by rednoah »

1.
The best solution is to build a container that contains both JD and FileBot so that JD can call filebot directly same as any other Linux platform:

:arrow: Setup for Windows, Linux and Mac OS X

:idea: Where did you copy your jdownloader-postprocess.sh script from? It's definitely not ours. Please read the official jdownloader-postprocess.sh to compare and contrast.




2.
If you can't build your own container, then you have many not-so-great options. You'll definitely need a "completed" folder where JD moves completed files, which you then take as input folder for filebot commands. Watching this folder is one option. Running filebot on a schedule is another. Personally, I'd schedule a filebot command to run once a day at 4am on all the newly added files.

:idea: You don't need to run filebot in a container, but you can if you don't mind a little bit of additional complexity. Personally, I would install filebot normally unless this is not possible on your host platform for one reason or another.




3.
Your custom format is responsible for the entire file name, including subtitle file names and language tags. If you use the {plex.id} format then everything will work by default, including 3-letter subtitle language codes and subtitle tags.

:arrow: Format Expressions

:arrow: {lang} and {subt} subtitle language tag

:arrow: Match information from the file path

:idea: You will want to use the Format Editor GUI to prototype your custom format expression first, before integrating it into an automated command-line call.
:idea: Please read the FAQ and How to Request Help.
updatefreak
Posts: 10
Joined: 03 Aug 2023, 21:16

Re: Combine FileBot and JDownloader (both as Docker-Container)

Post by updatefreak »

thanks for the quick answer and the information. I will check.
Now I have Jdownloader (lesage/jdownloader-2) and FileBot (jlesage/filebot) installed, because I can not build my own docker container with both included.
The jdownloader-postprocess.sh I copied to /volume1/docker/jdownloader2/scripts/jdownloader-postprocess.sh

The downloadfolder for Jdownloader is volume1/docker/jdownloader/output
One possibility is to set a schedule in Synology to execute the sh-script, but I think it makes more sense to trigger it while finished extraction of a downloaded archiv.
User avatar
rednoah
The Source
Posts: 22854
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Combine FileBot and JDownloader (both as Docker-Container)

Post by rednoah »

updatefreak wrote: 04 Aug 2023, 20:33 I think it makes more sense to trigger it while finished extraction of a downloaded archiv.
It does, but since docker containers are separate machines for all accounts and purposes, one container cannot trigger something an another. You can send a network request, have the other listen to network requests and then do something in response to that, e.g. have a FileBot Node server running and start a prepared task via a curl command from the JD container. Possible, but not nearly as easy as having JD event scripter call filebot within the same machine.


:!: You can try to "communicate" via file system events, but that also may not work as reliably across different containers / machines as you might think. Notably, jlesage/filebot doesn't technically "watch" file system events and simply checks the file listing every 10 seconds to see if something has changed, so that's effectively the same as running on a schedule, with a small pre-check to see if we have work to do or not.
:idea: Please read the FAQ and How to Request Help.
updatefreak
Posts: 10
Joined: 03 Aug 2023, 21:16

Re: Combine FileBot and JDownloader (both as Docker-Container)

Post by updatefreak »

Now I changed to filebot-watcher in a docker container (without trigger through JDownloader).

Here I got the following error message:

Code: Select all

Waiting 300 seconds for changes to settle down...
Run script [fn:amc] at [Sat Aug 05 10:30:30 GMT 2023]
[PSA] Important Discussion of Changes effective as of 28 Apr 2023:
https://www.filebot.net/forums/viewtopic.php?t=13406
Parameter: excludeList = .excludes
Parameter: unsorted = y
Parameter: music = y
Parameter: artwork = y
Argument[0]: /volume1/docker/jdownloader2/output/extracted
Invalid usage: output folder must exist and must be a writable directory: /volume1/docker/jdownloader2/output/Test
Use excludes: /volume1/docker/jdownloader2/output/Test/.excludes
Failed to create excludes: /volume1/docker/jdownloader2/output/Test/.excludes: Permission denied
Abort (×_×)
User avatar
rednoah
The Source
Posts: 22854
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Combine FileBot and JDownloader (both as Docker-Container)

Post by rednoah »

The error message suggests that the output folder is not writable or does not exist, within the context of the running container:

Code: Select all

Invalid usage: output folder must exist and must be a writable directory: /volume1/docker/jdownloader2/output/Test

Code: Select all

Failed to create excludes: /volume1/docker/jdownloader2/output/Test/.excludes: Permission denied

:?: Are your bind mounts correct?
:idea: Please read the FAQ and How to Request Help.
updatefreak
Posts: 10
Joined: 03 Aug 2023, 21:16

Re: Combine FileBot and JDownloader (both as Docker-Container)

Post by updatefreak »

found now a solution for me:

Code: Select all

docker run -d --name=FileBot \
-p 5802:5800 \
-e USER_ID=1026 \
-e GROUP_ID=100 \
-e LANG=de_DE.UTF-8 \
-e TZ=Europe/Berlin \
-e AMC_ACTION=move \
-e AMC_CONFLICT=skip \
-e AMC_LANG=German \
-e AMC_MOVIE_FORMAT="Filme/{n}/{n} ({y})" \
-e AMC_SERIES_FORMAT="Serien/{n}/Staffel {s}/{n} - {s00e00} - {t}" \
-e AMC_PROCESS_MUSIC=n \
-e AMC_INPUT_DIR=/storage/docker/jdownloader2/output/extracted \
-e AMC_OUTPUT_DIR=/storage/docker/jdownloader2/output/test \
-v /volume1/docker/filebot:/config:rw \
-v /volume1:/storage:rw \
jlesage/filebot
This will work with the extracted folder.
For test purposes I will try this with the test folder as output.
Thanks for help
User avatar
rednoah
The Source
Posts: 22854
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Combine FileBot and JDownloader (both as Docker-Container)

Post by rednoah »

I see. You were using the host path /volume1 which does not exist inside the container as you are mapping /volume1 to /storage inside the container. A common mistake. Containers are tricky that way.
:idea: Please read the FAQ and How to Request Help.
Post Reply