Need help running Filebot AMC script from qBittorrent

Support for Ubuntu and other Desktop Linux distributions
Post Reply
adamd
Posts: 5
Joined: 17 Dec 2022, 12:49

Need help running Filebot AMC script from qBittorrent

Post by adamd »

Hello there,

After a few days of attempting to resolve this issue using informaiton online I decided that I need help. My problem is that whenever I enter the file path for my amc script in the 'Run external program on torrent completion' field in qBittorrent, the script won't run no matter what. Some details:

I'm running qBittorrent-nox on a Raspberry Pi 4B. My Synology NAS is mounted via NFS into my /mnt folder on my Raspberry Pi. And the amc script is stored on my RPi.

Here is my script:

Code: Select all

#!/bin/bash
#Filebot AMC script
filebot -script 'fn:amc' \
--output "/mnt/Synology" \
--action move \
--conflict index -non-strict "/mnt/Synology/Completed" \
--order Airdate \
--lang en \
--def music="n" \
--def unsorted="y" \
--def clean="y" \
--def skipExtract="y" \
--def ignore=".srt|.exe|.txt" \
--def seriesFormat="/mnt/Synology/Library/Plex Media/TV Shows/{n} ({y})/{'\''Season '\''+s}/{n.space('\''.'\'')}.{s00e00}" \
--def movieFormat="/mnt/Synology/Library/Plex Media/{vf =~ /2160p/ ? '4K UHD Movies' : 'Movies'}/{n} ({y})/{n} ({y})" \
--def movieDB="TheMovieDB" \
--def seriesDB="TheTVDB" \
--def excludeList=".excludes" \
--apply refresh \
--log all \
--log-file /mnt/Synology/Misc/Filebot/logs/filebot.log;
The script itself works fine when I run it via bash in command line over ssh. Here is the Filebot log from a recent manual call:

Code: Select all

Run script [fn:amc] at [Sat Dec 17 11:53:30 GMT 2022]
Parameter: music = n
Parameter: unsorted = y
Parameter: clean = y
Parameter: skipExtract = y
Parameter: ignore = .srt|.exe|.txt
Parameter: seriesFormat = /mnt/Synology/Library/Plex Media/TV Shows/{n} ({y})/{'\''Season '\''+s}/{n.space('\''.'\'')}.{s00e00}
Parameter: movieFormat = /mnt/Synology/Library/Plex Media/{vf =~ /2160p/ ? '4K UHD Movies' : 'Movies'}/{n} ({y})/{n} ({y})
Parameter: movieDB = TheMovieDB
Parameter: seriesDB = TheTVDB
Parameter: excludeList = .excludes
Argument[0]: /mnt/Synology/Completed
Use excludes: /mnt/Synology/.excludes (0)
Ignore pattern: /mnt/Synology/Completed/American.Hustle.2013.1080p.BluRay.x264-SPARKS/RARBG.com.txt
Ignore pattern: /mnt/Synology/Completed/Avengers.Infinity.War.2018.1080p.BluRay.x264.TrueHD.7.1.Atmos-SWTYBLZ/RARBG.txt
Ignore pattern: /mnt/Synology/Completed/The.Avengers.2012.PROPER.1080p.BluRay.x264.TrueHD.7.1.Atmos-SWTYBLZ/RARBG.txt
Input: /mnt/Synology/Completed/American.Hustle.2013.1080p.BluRay.x264-SPARKS/american.hustle.2013.1080p.bluray.x264-sparks.mkv
Input: /mnt/Synology/Completed/Avengers.Infinity.War.2018.1080p.BluRay.x264.TrueHD.7.1.Atmos-SWTYBLZ/Avengers.Infinity.War.2018.1080p.BluRay.x264.TrueHD.7.1.Atmos-SWTYBLZ.mkv
Input: /mnt/Synology/Completed/The.Avengers.2012.PROPER.1080p.BluRay.x264.TrueHD.7.1.Atmos-SWTYBLZ/The.Avengers.2012.PROPER.1080p.BluRay.x264.TrueHD.7.1.Atmos-SWTYBLZ.mkv
Group: {Movie=American Hustle (2013)} => [american.hustle.2013.1080p.bluray.x264-sparks.mkv]
Group: {Movie=Avengers: Infinity War (2018)} => [Avengers.Infinity.War.2018.1080p.BluRay.x264.TrueHD.7.1.Atmos-SWTYBLZ.mkv]
Group: {Movie=The Avengers (2012)} => [The.Avengers.2012.PROPER.1080p.BluRay.x264.TrueHD.7.1.Atmos-SWTYBLZ.mkv]
Rename movies using [TheMovieDB]
Auto-detect movie from context [/mnt/Synology/Completed/American.Hustle.2013.1080p.BluRay.x264-SPARKS/american.hustle.2013.1080p.bluray.x264-sparks.mkv]
[MOVE] from [/mnt/Synology/Completed/American.Hustle.2013.1080p.BluRay.x264-SPARKS/american.hustle.2013.1080p.bluray.x264-sparks.mkv] to [/mnt/Synology/Library/Plex Media/Movies/American Hustle (2013)/American Hustle (2013).mkv]
Failed to set xattr: /mnt/Synology/Library/Plex Media/Movies/American Hustle (2013)/American Hustle (2013).mkv: Error writing extended attribute 'net.filebot.metadata': Operation not supported
Processed 1 file
Rename movies using [TheMovieDB]
Auto-detect movie from context [/mnt/Synology/Completed/Avengers.Infinity.War.2018.1080p.BluRay.x264.TrueHD.7.1.Atmos-SWTYBLZ/Avengers.Infinity.War.2018.1080p.BluRay.x264.TrueHD.7.1.Atmos-SWTYBLZ.mkv]
Stripping invalid characters from the output file path: /mnt/Synology/Library/Plex Media/Movies/Avengers: Infinity War (2018)/Avengers: Infinity War (2018).mkv
[MOVE] from [/mnt/Synology/Completed/Avengers.Infinity.War.2018.1080p.BluRay.x264.TrueHD.7.1.Atmos-SWTYBLZ/Avengers.Infinity.War.2018.1080p.BluRay.x264.TrueHD.7.1.Atmos-SWTYBLZ.mkv] to [/mnt/Synology/Library/Plex Media/Movies/Avengers Infinity War (2018)/Avengers Infinity War (2018).mkv]
Failed to set xattr: /mnt/Synology/Library/Plex Media/Movies/Avengers Infinity War (2018)/Avengers Infinity War (2018).mkv: Error writing extended attribute 'net.filebot.metadata': Operation not supported
Processed 1 file
Rename movies using [TheMovieDB]
Auto-detect movie from context [/mnt/Synology/Completed/The.Avengers.2012.PROPER.1080p.BluRay.x264.TrueHD.7.1.Atmos-SWTYBLZ/The.Avengers.2012.PROPER.1080p.BluRay.x264.TrueHD.7.1.Atmos-SWTYBLZ.mkv]
[MOVE] from [/mnt/Synology/Completed/The.Avengers.2012.PROPER.1080p.BluRay.x264.TrueHD.7.1.Atmos-SWTYBLZ/The.Avengers.2012.PROPER.1080p.BluRay.x264.TrueHD.7.1.Atmos-SWTYBLZ.mkv] to [/mnt/Synology/Library/Plex Media/Movies/The Avengers (2012)/The Avengers (2012).mkv]
Failed to set xattr: /mnt/Synology/Library/Plex Media/Movies/The Avengers (2012)/The Avengers (2012).mkv: Error writing extended attribute 'net.filebot.metadata': Operation not supported
Processed 1 file
Clean clutter files and empty folders
Delete /mnt/Synology/Completed/American.Hustle.2013.1080p.BluRay.x264-SPARKS/american.hustle.2013.1080p.bluray.x264-sparks.nfo
Delete /mnt/Synology/Completed/American.Hustle.2013.1080p.BluRay.x264-SPARKS/RARBG.com.txt
Delete /mnt/Synology/Completed/Avengers.Infinity.War.2018.1080p.BluRay.x264.TrueHD.7.1.Atmos-SWTYBLZ/RARBG.txt
Delete /mnt/Synology/Completed/The.Avengers.2012.PROPER.1080p.BluRay.x264.TrueHD.7.1.Atmos-SWTYBLZ/RARBG.txt
Delete /mnt/Synology/Completed/The.Avengers.2012.PROPER.1080p.BluRay.x264.TrueHD.7.1.Atmos-SWTYBLZ
Delete /mnt/Synology/Completed/Avengers.Infinity.War.2018.1080p.BluRay.x264.TrueHD.7.1.Atmos-SWTYBLZ
Delete /mnt/Synology/Completed/American.Hustle.2013.1080p.BluRay.x264-SPARKS
Keep /mnt/Synology/Completed (root folder)
Done ヾ(@⌒ー⌒@)ノ
And here is the qBittorrent log after testing with a few torrents:

Code: Select all

(N) 2022-12-17T01:13:06 - Web UI: Now listening on IP: *, port: 8081
(N) 2022-12-17T01:53:56 - WebAPI login success. IP: ::ffff:192.168.3.1
(N) 2022-12-17T01:53:57 - WebAPI login success. IP: ::ffff:192.168.3.1
(N) 2022-12-17T04:20:11 - WebAPI login success. IP: ::ffff:192.168.3.1
(N) 2022-12-17T04:22:47 - WebAPI login success. IP: ::ffff:192.168.3.1
(N) 2022-12-17T04:22:51 - Download first and last piece first: Off, torrent: 'The.Old.Man.And.The.Gun.2018.1080p.BluRay.x264.DTS-HD.MA.5.1-FGT'
(N) 2022-12-17T04:22:51 - 'The.Old.Man.And.The.Gun.2018.1080p.BluRay.x264.DTS-HD.MA.5.1-FGT' added to download list.
(N) 2022-12-17T04:24:36 - WebAPI login success. IP: ::ffff:192.168.3.1
(N) 2022-12-17T04:38:09 - 'The.Old.Man.And.The.Gun.2018.1080p.BluRay.x264.DTS-HD.MA.5.1-FGT' was removed from the transfer list and hard disk.
(N) 2022-12-17T04:39:23 - 'The.King’s.Man.2021.720p.10bit.BluRay.6CH.x265.HEVC-PSA' added to download list.
(N) 2022-12-17T04:39:46 - 'American Underdog (2021) (1080p BluRay x265 HEVC 10bit AAC 7.1 Tigole) [QxR]' added to download list.
(N) 2022-12-17T04:40:58 - 'Rampage (2018) [WEBRip] [720p] [YTS] [YIFY]' added to download list.
(N) 2022-12-17T04:57:16 - Successfully moved torrent: American Underdog (2021) (1080p BluRay x265 HEVC 10bit AAC 7.1 Tigole). New path: /mnt/Synology/Completed
(N) 2022-12-17T04:57:16 - Torrent: American Underdog (2021) (1080p BluRay x265 HEVC 10bit AAC 7.1 Tigole), running external program, command: /home/admin/Filebot/filebot.sh
(N) 2022-12-17T04:57:16 - Torrent: American Underdog (2021) (1080p BluRay x265 HEVC 10bit AAC 7.1 Tigole), sending mail notification
(N) 2022-12-17T05:38:15 - Successfully moved torrent: Rampage (2018) [WEBRip] [720p] [YTS.AM]. New path: /mnt/Synology/Completed
(N) 2022-12-17T05:38:15 - Torrent: Rampage (2018) [WEBRip] [720p] [YTS.AM], running external program, command: /home/admin/Filebot/filebot.sh
(N) 2022-12-17T05:38:15 - Torrent: Rampage (2018) [WEBRip] [720p] [YTS.AM], sending mail notification
(N) 2022-12-17T05:53:59 - Successfully moved torrent: The.King's.Man.2021.720p.10bit.BluRay.6CH.x265.HEVC-PSA. New path: /mnt/Synology/Completed
(N) 2022-12-17T05:53:59 - Torrent: The.King's.Man.2021.720p.10bit.BluRay.6CH.x265.HEVC-PSA, running external program, command: /home/admin/Filebot/filebot.sh
(N) 2022-12-17T05:53:59 - Torrent: The.King's.Man.2021.720p.10bit.BluRay.6CH.x265.HEVC-PSA, sending mail notification
(N) 2022-12-17T06:36:07 - 'American Underdog (2021) (1080p BluRay x265 HEVC 10bit AAC 7.1 Tigole)' reached the maximum seeding time you set. Removed.
(N) 2022-12-17T06:36:07 - 'American Underdog (2021) (1080p BluRay x265 HEVC 10bit AAC 7.1 Tigole)' was removed from the transfer list.
(N) 2022-12-17T07:08:17 - 'Rampage (2018) [WEBRip] [720p] [YTS.AM]' reached the maximum seeding time you set. Removed.
(N) 2022-12-17T07:08:17 - 'Rampage (2018) [WEBRip] [720p] [YTS.AM]' was removed from the transfer list.
(N) 2022-12-17T07:24:07 - 'The.King's.Man.2021.720p.10bit.BluRay.6CH.x265.HEVC-PSA' reached the maximum seeding time you set. Removed.
(N) 2022-12-17T07:24:07 - 'The.King's.Man.2021.720p.10bit.BluRay.6CH.x265.HEVC-PSA' was removed from the transfer list.
(N) 2022-12-17T12:54:20 - WebAPI login success. IP: ::ffff:192.168.4.2
admin@RaspberryPi:~ $
Note the lines with:

Code: Select all

running external program, command: /home/admin/Filebot/filebot.sh
However this file is never called and I can't for the life of me figure out why. I tried encapsulating the command in quotation marks and adding the 'bash' command before the file path. I was previously running qBittorrent in a Docker container on my Synology but read somewhere on the forums that the amc script is not supported in containers, so I had migrated my setup out of a container and installed the headless program (nox) on my other server, which I was planning to do anyway as there can be issues with directories in Docker. I should also note I also installed Filebot on my Pi using the deb.sh script and activated my license.

Also if you could address this error as I'm not entirely sure why I'm getting it:

Code: Select all

Error writing extended attribute 'net.filebot.metadata': Operation not supported
That would be appreciated, thanks for any help in advance
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Need help running Filebot AMC script from qBittorrent

Post by rednoah »

How did you confirm that /home/admin/Filebot/filebot.sh is indeed called or not called? Please read How to debug scripts that are called by other tools? and confirm:
viewtopic.php?t=3067


:arrow: If qBT says that your shell script was called, then your shell script was most likely called. Your script is not redirecting console output to a file, so you can't know what the console output said when the script was called by qBT and then failed for some reason. You'll want to redirect console output to a file so that you can check what the console output said when the script failed.




Unrelated to the problem above:

:idea: Note that -script fn:amc does not refer to a file in your file system. -script fn:amc refers to the built-in script repository that is downloaded / cached / updated internally. If you download the amc.groovy file and then put it somewhere (where would you put in anyway?) then that file won't be used.

:idea: Error writing extended attribute 'net.filebot.metadata': Operation not supported means that xattr metadata does not work on the source or target file system. You can disable xattr, or configure FileBot to store xattr into plain text files instead of file system xattr, or enable file system xattr in your remote file system / mount configuration.
:idea: Please read the FAQ and How to Request Help.
adamd
Posts: 5
Joined: 17 Dec 2022, 12:49

Re: Need help running Filebot AMC script from qBittorrent

Post by adamd »

Hello and thank you for your reply, I assumed that my script wasn't being called by inspecting the Filebot log file in /mnt/Synology/Misc/Filebot/logs/filebot.log. As the log only contained output from when I manually ran the script I inferred qBittorrent wasn't calling the script at all.

However, I followed your shell scripting troubleshooting guide as you suggested and the debug.sh script works perfectly. I've included the output below of the tail /tmp/*.txt command. I have omitted my username and password for the SOCKS5 proxy I'm using.

Code: Select all

admin@RaspberryPi:/tmp $ tail /tmp/*.txt
==> /tmp/date.txt <==
Sun 18 Dec 2022 01:56:25 PM GMT

==> /tmp/filebot-sysenv.txt <==
user.dir: /
user.home: /home/admin
user.language: en
user.name: admin
user.timezone: Europe/London

# Arguments #
args[0] = -script
args[1] = fn:sysenv
Done ヾ(@⌒ー⌒@)ノ

==> /tmp/filebot-sysinfo.txt <==
CPU/MEM: 4 Core / 492 MB Max Memory / 25 MB Used Memory
OS: Linux (arm)
HW: Linux RaspberryPi 5.15.61-v7l+ #1579 SMP Fri Aug 26 11:13:03 BST 2022 armv7l GNU/Linux
CPU/MEM: ARMv7 Processor rev 3 (v7l) | BCM2711 [MemTotal: 2.0 GB | MemFree: 100 MB | MemAvailable: 1.3 GB | SwapCached: 7 MB | SwapTotal: 104 MB]
STORAGE: NONE
USER: admin
DATA: /home/admin/.filebot
Package: DEB
License: FileBot License PX39599380 (Valid-Until: 2072-07-27)
Done ヾ(@⌒ー⌒@)ノ

==> /tmp/filebot-version.txt <==
FileBot 4.9.6 (r9125) / OpenJDK Runtime Environment 11.0.16

==> /tmp/java-version.txt <==
openjdk version "11.0.16" 2022-07-19
OpenJDK Runtime Environment (build 11.0.16+8-post-Raspbian-1deb11u1)
OpenJDK Server VM (build 11.0.16+8-post-Raspbian-1deb11u1, mixed mode)

==> /tmp/printenv.txt <==
https_proxy=
LOGNAME=admin
JOURNAL_STREAM=8:899558
http_proxy=
sock_proxy=[omitted]
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
INVOCATION_ID=a2442a7b4a6d4c22a6b0d063de8ae203
LANG=en_US.UTF-8
SHELL=/bin/bash
PWD=/

==> /tmp/whoami.txt <==
admin
Here is the portion of the qBittorrent log where debug.sh was called:

Code: Select all

(N) 2022-12-18T13:53:20 - WebAPI login success. IP: ::ffff:192.168.4.2
(N) 2022-12-18T13:53:30 - Web UI: Now listening on IP: *, port: 8081
(N) 2022-12-18T13:55:36 - 'The.Guardians.of.the.Galaxy.Holiday.Special.2022.WEBRip.x264-ION10' added to download list.
(N) 2022-12-18T13:56:25 - Successfully moved torrent: The.Guardians.of.the.Galaxy.Holiday.Special.2022.WEBRip.x264-ION10. New path: /mnt/Synology/Completed
(N) 2022-12-18T13:56:25 - Torrent: The.Guardians.of.the.Galaxy.Holiday.Special.2022.WEBRip.x264-ION10, running external program, command: /home/admin/debug.sh
(N) 2022-12-18T13:56:25 - Torrent: The.Guardians.of.the.Galaxy.Holiday.Special.2022.WEBRip.x264-ION10, sending mail notification
admin@RaspberryPi:/tmp $
When you say
Your script is not redirecting console output to a file, so you can't know what the console output said when the script was called by qBT and then failed for some reason.
Do you mean the filebot.sh script isn't logging itself? I have included --log-file /mnt/Synology/Misc/Filebot/logs/filebot.log; in my script at the very end which does log the output of the filebot script, and because there is no output when I attempt to run it through qBittorrent I assumed it wasn't being called at all.

Also thank you for your explanation of the error in your footnote
adamd
Posts: 5
Joined: 17 Dec 2022, 12:49

Re: Need help running Filebot AMC script from qBittorrent

Post by adamd »

I wanted to update this thread again as I have managed to resolve my problem and figured out it was actually a permissions issue.

I had copied the script from my NAS to my Pi and after checking the permissions of the file it showed this:

Code: Select all

-rw-r--r-- 1 admin admin 722 Dec 18 18:24 /home/admin/filebot.sh
I am not too knowledgable with Linux permissions but I read on the UNIX Stack Exchange that chmod -R 777, would allow the file to be available to all users.

I ran this command for my script and when checking the file permissions again it looks like the file can be read and written to by all users on the machine:

Code: Select all

admin@RaspberryPi:~ $ ls -l /home/admin/Filebot/filebot.sh
-rwxrwxrwx 1 admin admin 722 Dec 18 17:59 /home/admin/Filebot/filebot.sh
I'm not exactly sure why this works but it now is working exactly the way I want it to. Hope this can help anyone in the future. Thank you for your earlier reply rednoah and for this great software!
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Need help running Filebot AMC script from qBittorrent

Post by rednoah »

adamd wrote: 18 Dec 2022, 14:19 Do you mean the filebot.sh script isn't logging itself? I have included --log-file /mnt/Synology/Misc/Filebot/logs/filebot.log; in my script at the very end which does log the output of the filebot script, and because there is no output when I attempt to run it through qBittorrent I assumed it wasn't being called at all.
What happens if filebot is not installed? What happens if filebot is not executable? --log-file is a filebot option, and filebot won't be writing any logs if filebot is not executed. BUT the console will always print an error message that will tell you exactly what's not working, and that's the error message you'll want to capture and write to a file.


e.g. console output:

Code: Select all

$ /path/to/script.sh
zsh: no such file or directory: /path/to/script.sh

e.g. redirect console output to a file so that you can check it later:

Code: Select all

$ /path/to/script.sh > output.txt 2>&1
$ cat output.txt
zsh: no such file or directory: /path/to/script.sh

e.g. redirect console output means that the currently running shell is writing the file, and not any one particular command which may or may not work:

Code: Select all

$ (
  echo START
  filebot -version
  /path/to/script.sh
  echo END
) > output.txt 2>&1
$ cat output.txt
START
FileBot 4.9.6
zsh: no such file or directory: /path/to/script.sh
END

How to Redirect stderr to stdout in Bash wrote:Understanding the concept of redirections and file descriptors is very important when working on the command line.
:arrow: https://linuxize.com/post/bash-redirect-stderr-stdout/
:idea: Please read the FAQ and How to Request Help.
Post Reply