Page 1 of 1

[ENTRYPOINT] Help creating custom automation (Noob)

Posted: 04 Mar 2025, 00:07
by ste
Hi everyone,

I am new to the automation and scripting side of things and I'm having a hard time learning it to be honest. I could do with watching a really good video tutorial where someone takes you through creating a script and not only explaining options but how to correctly fit them into the script (what rules need to be followed so they are used legally, etc), not just a reference to commands. Anyway, I have some requirements for how I want to setup filebot but don't know what it can fulfill. can someone advise on how realistic these requirements are and suggest a script that could achieve them please?

I am running FileBot on my Synology DS920+ NAS (running in a container). I have a structured media library and specific automation needs. Below are my requirements:

1. File Naming and Organization

I need FileBot to use these naming schemes that sorts media into these categories (is it possible to organise 3D/VR movies separately?):
• Movies → /Movies/{n} {y} {tmdb-{tmdbid}}/{n} {y} {tags} [{vf}] [{channels}] [{certification}] [{rating}]
• 3D/VR Movies → /3DVR Movies/{n} {y} {tmdb-{tmdbid}}/{n} {y} {tags} [3DVR] [{vf}] [{channels}] [{certification}] [{rating}]
• TV Shows → /TV Shows/{n} ({y}) {tvdb-{tvdbid}}/{'Season '+s00} {sy}/{n} - {s00e00} {t} {subt} {tags} [{vf}] [{channels}]

2. Handling Matches & Sorting
• Match Confidence: Strict matching, if FileBot’s confidence score is below 95, move the file to an /data1/filebot/unmatched folder for manual review, with subfolders for
Movies, TV Shows, and 3D/VR Movies.
• Duplicates: If a file already exists in my library, move the duplicate to a /data1/filebot/duplicates folder, with subfolders for Movies, TV Shows, and 3D/VR Movies.
• Adult Content: I want adult videos matched and moved to /x/X/X Vidz. To ensure FileBot properly matches adult content, I believe I need to enable (but don't know where or how I put this, in the amc script somewhere?):

filebot -script fn:properties --def net.filebot.TheMovieDB.adult=true

However, I understand that adultFormat= and adultDB=ThePornDB are not valid FileBot variables, so I need guidance on correctly configuring ThePornDB.

3. Handling Extras & Subtitles
• When handling downloaded torrents I want filebot to move all included files with the media that it matches and organises (whether matched, unmatched or duplicates), except
for specific files such as files containing "YTS" or "torrentdownload" in their filenames, for example.
• Extras should automatically be organised into a subfolder named “Other”, with recognized extras (e.g., Behind the Scenes, Featurettes, Interviews) placed in named subfolders
within 'Others'; according to Plex’s requirements.
• Subtitle handling: Only keep forced English subtitles and move them alongside the video file, unless the film is in fact a foreign film. In this case filebot should include the full
English subtitles.
Can filebot also keep only the english audio tracks (or the main audio track if it is a foreign video and there is no dubbed english track)?

4. Logging & Automation
• I need logs for all actions stored in /logs, with separate files for unmatched.log, duplicates.log, matched.log, errors.log

• Filebot to remove illegal characters (e.g., ?, emojis) as well as replacing:
• ":" → " -"
• "|" → "-"

Automation should run on:
• All media found in the watch folders listed below.
• On container startup and at regular intervals but for filebot to wait 60 seconds after detecting newly completed torrents so that qbittorrent has time to move all files to the
watch folder fully before filebot begins processing.
• Media I manually import, with the ability to choose presets for different media types (I have created these presets already).


5. Watch & Destination Paths

FileBot should process media from the following watch folders and move them to their final destinations and then symbolically linked back to a seeding folder. I plan to implement audio file processing at a later date.

Watch Folders (Completed Torrents are moved here by qbittorrent)
• /data1/media/video/movies → Movies
• /data1/media/video/3dvr → 3D/VR Movies
• /data1/media/video/tv_shows → TV Shows
• /data1/media/video/music_videos → Music Videos
• /data1/media/x/x → Adult Videos
• /data1/media/video/videos → General Videos
• /data1/media/audio/music → Music
• /data1/media/audio/audiobooks → Audiobooks
• /data1/media/audio/podcasts → Podcasts

Final Destination Paths (Move Processed Media Here)
• /volume1/Media/Movies/
• /volume1/Media/3DVR Movies/
• /volume1/Media/TV Shows/
• /volume1/Media/Music Videos/
• /volume1/Media/X Vidz/ (Adult)
• /volume1/Media/General Videos/
• /volume1/Media/Music/
• /volume1/Media/Audiobooks/
• /volume1/Media/Podcasts/

Seeding Paths (filebot to symlink not only the media's root folder back to subfolders (named by category like Movies, 3DVR Movies, TV Shows), within the "/data1/seeding/" folder, but also all other accompanying files so that qbittorrent can continue to seed the torrents. This will mean that filebot would need to remember what the torrents files were originally named and then name the symlinks the same so qbittorrent can still find them.
Is this possible? ( I really don't want to just keep all completed torrents in one messy folder and then create symlinks from them to a video folder for plex to use, i'd prefer to move the files to my organise media folders and then symlink back)

I am using /data1/ for the actual /data/ folder path on my NAS because, as I understand, the filebot container needs /data/ assigned for filebot/data/. Is this correct? otherwise, I will just use /data/ for my paths instead of /data1/. (I hope that makes sense? LOL)

6. Additional Questions:
1. Can FileBot automatically detect whether a video is a movie, 3D/VR movie, adult movie, TV show, or music video based on metadata? If so, what’s the best method to configure this? or can the script help filebot know how to handle the files in the watch folders according to their path and then apply different ways of handling (such as applying different naming formats)?
2. Is there a valid way to set FileBot to use ThePornDB for adult content?
3. How can I ensure logs are persistent in my container setup?
4. What does the amc script support in terms of coding languages such as bash, groovy, regular expressions, etc?

I’d appreciate any help with configuration for this automated setup.

I know this is a lot of requirements but I am struggling to understand what filebot can/can't do and how to automate any of this. Hopefully someone is up for the challenge of helping me through this :D

Re: Help creating custom automation (Noob)

Posted: 04 Mar 2025, 09:47
by rednoah
Learning how to use the command-line is trial and error. You run your command. You look at the output. Change your command in response. Repeat until your command does what you want it to do.


A.
You can name and organise 3D / VR / etc differently from other content, assuming there is some way to tell which is which. The {s3d} binding, the MediaInfo Inspector, and Conditional Structures (if-then-else) will get you started.


B.
FileBot does not have the concept of a confidence score. You'll want to use Strict Mode if you require a mostly exact match. If you're using the command-line, then Strict Mode is default unless otherwise specified.


C.
The amc script will move unsorted files into a separate folder Unsorted folder if so configured.


D.
If --conflict skip (default) is set, then filebot will not overwrite destination files, meaning the source file cannot be processed. If you're using amc script, then such files are processed as Unsorted. If you must have a Duplicates folder for such cases, then you could write a Custom Conflict Action to do the job as desired. There's probably a few other ways to go about it as well.


E.
FileBot does not support adult content or adult content databases. You can however set net.filebot.TheMovieDB.adult=true to make TheMovieDB not filter results. Alternatively, you may be able to write your own code to talk to your own database or website. See Plain File Mode, Custom Scraper and Match custom patterns and rewrite file paths for details and examples.


F.
You can use the Import companion files feature to copy along Companion Files. You can write your own Custom Post-Processing Script if you need something other than the default behaviour.


G.
FileBot will move subtitles alongside the video file by default. You can write a Custom Post-Processing Script to selectively delete subtitle files after processing.


H.
FileBot does not modify media files, so you can't selectively copy video / audio streams to the destination path. But you could write a Custom Post-Processing Script to selectively call ffmpeg to remux the file at hand depending on the characteristics of the file at hand.


I.
The --log-file option will write all the logging you need into a log file. You might need to write your own tools (i.e. grep commands) to filter the log for specific lines and pieces of information. You could also write a Custom Post-Processing Script to do additional custom logging to whichever file you want in whichever format you want.


J.
The destination file path is entirely up to your Custom Format Expressions, including any character replacement you see fit. That said, if your custom format generates a file path that includes invalid characters, then filebot will strip them automatically, unless configured otherwise.


K.
The amc script itself does not monitor files. You can call it yourself, or set up a scheduler of some kind to call it automatically as needed. How do I monitor a folder and call filebot on newly added files? and How do I use the rednoah/filebot:watcher docker container? will get you started on calling the amc script in response to file system events.


L.
You can use the --action option to create hardlinks / symlinks / etc instead of moving files. The --action KEEPLINK (i.e. move file and create a relative symlink to the new path in its place) option seems to be what you're looking for, but you can of course write your own as well if the built-in --action options do not do what you want to do.


M.
If all your files are on the same NAS / same file system the you could just use hardlinks. That way you can have the same file multiple times at different file paths and not have to worry about which is a symbolic link and which isn't.


N.
The rednoah/filebot container does indeed require you to specify -v "data:/data" where it will then store persistent application data / caches / settings / etc. I'd do -v "/volume1/Media:/volume1/Media" (i.e. single bind mount that exposes all the media folders) so that the file paths inside the container context match exactly the file paths on the host.


O.
The amc script is written in Groovy. That said, you would not be expected to read or modify the amc script code itself. All topics discussed above are essentially about adding additional command-line options (some very simple; some possibly very complex) to your amc script command.





Note that each individual point from A to O could be a dedicated topic in itself. Anything is possible, but you're trying to build Rome and Rome wasn't built in a day. If you're new to programming then you will face a steep learning curve, here or there. Learning a new skill for your own passion project will be very rewarding though, and you can do things one step at a time, getting a rewarded for each step completed. Good luck!

Re: [ENTRYPOINT] Help creating custom automation (Noob)

Posted: 04 Mar 2025, 16:24
by ste
Hi rednoah. Thank you for replying and for your help. It has helped me understand many complexities about filebot programming, of which i couldn't see a straight forward way to discovering (this could be because i just didn't happen to click on the correct pages or something). I really appreciate it anyway.

Regarding m and n:
Unfortunately my torrents download to a volume named "data" (which causes issues with the requirement for a data mount for filebot and why i labelled that path as "data1" to try and prevent issues, I'm not sure if it solves the problem though?). I wanted filebot to pick up the torrents from there and process them, moving them to another volume (which is not actually /volume1/media/ but I didn't change it as I thought I could just do that in any scripting people offered to me) which is /volume2/video/ (and /volume1/music/). So i don't think hardlinks will work. Is there any problems that can arise from using symlinks instead?

Re: [ENTRYPOINT] Help creating custom automation (Noob)

Posted: 04 Mar 2025, 17:40
by rednoah
ste wrote: 04 Mar 2025, 16:24 Regarding m and n:
M - unfortunately my torrents download to a volume named "data" (which causes issues with the requirement for a data mount for filebot and why i labelled that path as "data1" to try and prevent issues, I'm not sure if it solves the problem though?). I wanted filebot to pick up the torrents from there and process them, moving them to another volume (which is not actually /volume1/media/) which is /volume2/video/ (and /volume1/music/). So i don't think hardlinks will work. Is there any problems that can arise from using symlinks instead?
I see no particular issue. You define bind mounts for each container, so /data inside one container and /xyz inside another container can refer to the exact same folder, depending on the bind mount you specify for each container. If you use different containers with different bind mounts where the same file has a different file path depending the context, then symbolic links (i.e. think text file that contains a file path) become tricky. That's another reason to just do -v /volume1:/volume1 for all your containers so that same file path makes sense across containers and on the host. In any case, with only a single NAS device at play, I would assume that you have 1 file system on this 1 device that covers all the drives in some sort or RAID configuration, so hardlinks would be the way to go there.

Re: [ENTRYPOINT] Help creating custom automation (Noob)

Posted: 04 Mar 2025, 23:55
by ste
Ok yes that makes sense. I have two volumes though because i have a synology dx517 and it's bad to have the same volume spanned across the nas and the expansion unit. But both /data (where downloads are started and completed) and /video are on the same volume (/volume2) so that would work. Music is another story though because it's stored on volume 1 not volume 2.

Well I've got lots of reading and learning to do now. Thanks for pointing me in the right direction.

Re: [ENTRYPOINT] Help creating custom automation (Noob)

Posted: 05 Mar 2025, 07:03
by rednoah
ste wrote: 04 Mar 2025, 23:55 I have two volumes though because i have a synology dx517 and it's bad to have the same volume spanned across the nas and the expansion unit. But both /data (where downloads are started and completed) and /video are on the same volume (/volume2) so that would work.
Since you have downloads / organised media files on the same volume / file system, move operations will be instant and hardlink operations will be possible. What is a hardlink? explains things in detail. Do make sure to read and understand Notes on Docker Bind Mounts as well though. A common docker user error is unnecessarily using multiple volumes, which leads to the same file system appearing as two different file systems to the processes running inside the container, which leads unnecessary to physical copy + delete operations even if files are actually just moved from one folder to another on the same file system.