Setting up "on finish" script - Transmission + Synology NAS

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
Cinder
Posts: 20
Joined: 17 Jun 2015, 19:22

Setting up "on finish" script - Transmission + Synology NAS

Post by Cinder »

Hi,

I'm trying to setup a configuration where finished Transmission downloads on my Synology NAS will be hardlinked from the default "Downloads" folder to my Kodi folder structure.
I've managed to set up FileBot properly so I can run it on the NAS, however now I'm looking at the scripting and here are my questions:
  1. The AMC script - how are the paths specified in this script, should I download the script locally if I want to specify my own paths on my disk? (Talking about the --output argument)
  2. When running a script "on torrent finish" via Transmission, some arguments in the transmission-postprocess.sh script are the same as found in the AMC script. Am I correct to assume that the arguments in the .sh script are passed down to the AMC script, or does it work some other way? (For instance --output and --action are both in the postprocess and AMC scripts.)
  3. I am only going to use the AMC script for TV series, and I set the input folder so that it will only contain TV series in the future, do I need to worry about the code for movies and music in the AMC script and it doing something odd?
  4. Will FileBot keep going through all files in my "Downloads" folder, even though they've been processed before? Will it get bogged down in the long run when the files in the input folder become more numerous (as I don't plan on ever moving them from there)?
  5. Can I get transmission to run the FileBot node settings "on torrent finish" somehow? Are those settings stored somewhere with easy access? Would this be a good option instead of the transmission post process (like run FB Node on an hourly schedule or something similar?)
Any and all help is much appreciated!
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Setting up "on finish" script - Transmission + Synology

Post by rednoah »

1.
Scripts listed here can easily be called via -script fn:name. FileBot will automatically fetch and cache the code from GitHub.
You don't need to download anything. Everything is configured via cmdline options.

2.
transmission passes variables to your post process script, the post process script calls filebot/amc and passes these variables along.

3.
Yes. See Advanced Fine-Tuning.
You can force Movie/TV Show/Anime mode or force ignore files via labels, e.g. label as movie to force TheMovieDB, or tv to force TheTVDB, or anime to force AniDB, or other to ignore all files
In this case it's best to set --def "ut_label=TV" to force TV mode.

4.
Note that if you call this script in intervals every hour or every day you must set --def excludeList or you will get banned.
Yes. If you keep going through all your files repeatedly you will be banned.

But if things are set up correctly filebot/amc will only be called once on the newly completed files/folders, and never on the download folder itself.

Code: Select all

--def "ut_dir=$TR_TORRENT_DIR/$TR_TORRENT_NAME"
It should never be called repeatedly on the same folder, unless you keep track of processed files via --def excludeList.

5.
I have no idea. FileBot Node doesn't have settings. It just helps to create filebot/amc calls, that you can copy & paste at will.

You can run things daily via scheduler on your download root folder of course, given that you're using the excludeList feature to keep track of already processed files. That's just clickly-clicky in FileBot Node.
:idea: Please read the FAQ and How to Request Help.
Cinder
Posts: 20
Joined: 17 Jun 2015, 19:22

Re: Setting up "on finish" script - Transmission + Synology

Post by Cinder »

1.
You don't need to download anything. Everything is configured via cmdline options.
My concern is partially with the folder structure formatting, in amc.groovy the tv folder structure is "TV Shows/{n}/{episode.special...} and so on. If I want to change something, like the name of the folder "TV Shows", doesn't that mean I have to download amc.groovy and change it locally, or am I confusing things?


3.
Yes. See Advanced Fine-Tuning.
You can force Movie/TV Show/Anime mode or force ignore files via labels, e.g. label as movie to force TheMovieDB, or tv to force TheTVDB, or anime to force AniDB, or other to ignore all files
In this case it's best to set --def "ut_label=TV" to force TV mode.
Excellent, this is perfect.


4.
Note that if you call this script in intervals every hour or every day you must set --def excludeList or you will get banned.
Yes. If you keep going through all your files repeatedly you will be banned.

But if things are set up correctly filebot/amc will only be called once on the newly completed files/folders, and never on the download folder itself.

Code: Select all

--def "ut_dir=$TR_TORRENT_DIR/$TR_TORRENT_NAME"
It should never be called repeatedly on the same folder, unless you keep track of processed files via --def excludeList.
Excellent, I will set it up then. Just curious about where the file ends up if you use --def excludeList=amc-input.txt?
Is the above a correct use of the argument, or should it be a complete path like --def excludeList="/volume1/scripts/amc-input.txt"

  • Furthermore; when using "--def xbmc=host" to rescan library, can this be done as a background process or does Kodi/XBMC need to be running on the host machine?
  • And finally, subtitles are downloaded using hash checks, but is it possible to specify which folder they are downloaded to? I have a single folder "/volume1/subtitles/" for all my shows to keep the folders containing the video files less cluttered.
Thanks for all your help this far!
Last edited by Cinder on 18 Jun 2015, 08:18, edited 1 time in total.
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Setting up "on finish" script - Transmission + Synology

Post by rednoah »

1.
No. You can pass in your own formats. Please read the Change how files will be organized and renamed section.

4.
Relative and absolute paths are ok. The console output would have told you everything you want to know if you had just tried it once or twice. You should always do a few test runs just to see what it's doing.

5.
HOST is the hostname or IP of the computer that's running Kodi. Kodi has to be active and accepting TCP connections and it'll only work on the local network. It's merely sending a command to Kodi and then Kodi will do it's thing.
:idea: Please read the FAQ and How to Request Help.
Cinder
Posts: 20
Joined: 17 Jun 2015, 19:22

Re: Setting up "on finish" script - Transmission + Synology

Post by Cinder »

1.
No. You can pass in your own formats. Please read the Change how files will be organized and renamed section.
Thanks.
4.
Relative and absolute paths are ok. The console output would have told you everything you want to know if you had just tried it once or twice. You should always do a few test runs just to see what it's doing.
Thanks for clarifying, and yes, I will do some testing tonight, I'm at work and wanted to get a head start for later.
5.
HOST is the hostname or IP of the computer that's running Kodi. Kodi has to be active and accepting TCP connections and it'll only work on the local network. It's merely sending a command to Kodi and then Kodi will do it's thing.
This is a bit of a shame on Kodi's side that you can't runt update commands without running Kodi itself, oh well.

I looked around some more about the subtitle download folder, but I can't find any options for that in the arguments? Is the only option to download them into the episode folder?
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Setting up "on finish" script - Transmission + Synology

Post by rednoah »

Subtitles will always be stored along-side the files, as per convention.

You can mess with that in the format of course... but if you do your own thing but then Kodi probably won't find the subs.
:idea: Please read the FAQ and How to Request Help.
Cinder
Posts: 20
Joined: 17 Jun 2015, 19:22

Re: Setting up "on finish" script - Transmission + Synology

Post by Cinder »

rednoah wrote:Subtitles will always be stored along-side the files, as per convention.

You can mess with that in the format of course... but if you do your own thing but then Kodi probably won't find the subs.
Yes I know the convention, but just FYI Kodi actually supports a custom subtitles folder now which contains all subs.
However I might just go with the standard option of keeping them next to the episodes, less hassle I guess.

Cheers!
Cinder
Posts: 20
Joined: 17 Jun 2015, 19:22

Re: Setting up "on finish" script - Transmission + Synology

Post by Cinder »

I have come across one more issue when testing using the CLI now, everything seems to work except mediainfo.
My NAS is a Synology DS412+ and I installed the MedianInfo package from the community package center.

However, when I run an operation and my format comes to the tags ".{vf}.{vc}.{ac}{'-'+group}" the result is "Name...-GROUP.mkv".
Do I need to do something more to get mediainfo to work properly even if I installed it from the community package? The group name works, but not vf, vc and ac.
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Setting up "on finish" script - Transmission + Synology

Post by rednoah »

Nope, it should work out of the box. It seems the SynoCommunity native library is broken on Intel 32-bit architecture. I can only test armv7 and it works fine here. You might be able to get it to work by using the generic linux binaries from the mediainfo website. Since it's all 32-bit x86 Linux it might work.
:idea: Please read the FAQ and How to Request Help.
Cinder
Posts: 20
Joined: 17 Jun 2015, 19:22

Re: Setting up "on finish" script - Transmission + Synology

Post by Cinder »

rednoah wrote:Nope, it should work out of the box. It seems the SynoCommunity native library is broken on Intel 32-bit architecture. I can only test armv7 and it works fine here. You might be able to get it to work by using the generic linux binaries from the mediainfo website. Since it's all 32-bit x86 Linux it might work.
I'm still trying to figure this out. Here's my sysinfo:
FileBot 4.6 (r3052)
JNA Native: 4.0.0
MediaInfo: java.lang.UnsatisfiedLinkError: Unable to load library 'mediainfo': Native library (linux-x86/libmediainfo.so) not found in resource path ([file:/volume1/@appstore/filebot/FileBot.jar])
p7zip: Version 9.20 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,4 CPUs)
chromaprint-tools: java.io.IOException: Cannot run program "/usr/local/chromaprint/bin/fpcalc": error=2, No such file or directory
Extended Attributes: OK
Groovy Engine: 2.4.3
JRE: Java(TM) SE Embedded Runtime Environment 1.8.0_33 (headless)
JVM: 32-bit Java HotSpot(TM) Embedded Client VM
CPU/MEM: 4 Core / 239 MB Max Memory / 13 MB Used Memory
OS: Linux (i386)
I tried downloading the files from your repository for i686 according to another thread, however I can't get them to work.
Looking in filebot.sh the only path I find for libraries are the 3rd party libraries SYNO_LIBRARY_PATH="/usr/local/mediainfo/lib".
I dropped the files from your repo in there but that didn't do anything.

What files do I need from the mediainfo website?
As far as I gather I need the file: http://mediaarea.net/download/binary/me ... ce.tar.bz2
Where am I supposed to put it, and do I need to install it? I'm not a programmer so compiling this seems a very daunting task :/
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Setting up "on finish" script - Transmission + Synology

Post by rednoah »

You don't need to "install" anything, just copy some files. If it's in the library path and it still doesn't work, then it's because it's incompatible for some reason and simply doesn't work.

If you think not found means it can't find the library you're wrong. It just means it doesn't work. The low-level error codes are usually pretty misleading.

These are confirmed to work on x86 (at least on some of them):
https://sourceforge.net/p/filebot/code/ ... inux-i686/

And you will need libmediainfo.so and libzen.so for it to work.
:idea: Please read the FAQ and How to Request Help.
Cinder
Posts: 20
Joined: 17 Jun 2015, 19:22

Re: Setting up "on finish" script - Transmission + Synology

Post by Cinder »

rednoah wrote:You don't need to "install" anything, just copy some files. If it's in the library path and it still doesn't work, then it's because it's incompatible for some reason and simply doesn't work.

If you think not found means it can't find the library you're wrong. It just means it doesn't work. The low-level error codes are usually pretty misleading.

These are confirmed to work on x86 (at least on some of them):
https://sourceforge.net/p/filebot/code/ ... inux-i686/

And you will need libmediainfo.so and libzen.so for it to work.
I got it to work now when I put the files from sourceforge into SYNO_LIBRARY_PATH="/usr/local/mediainfo/lib"
Thanks man!

PS. I also added a few release groups to your groups thread, I'll drop them here too for convenience:

TV Releases:
MAGiC
GLF
IMDTHS
Last edited by Cinder on 19 Jun 2015, 09:40, edited 1 time in total.
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Setting up "on finish" script - Transmission + Synology

Post by rednoah »

1.
What changed? Isn't that what you just tried previously?

2.
Something doesn't work? Send the paths so I can confirm the problem myself.
:idea: Please read the FAQ and How to Request Help.
Cinder
Posts: 20
Joined: 17 Jun 2015, 19:22

Re: Setting up "on finish" script - Transmission + Synology

Post by Cinder »

rednoah wrote:1.
What changed? Isn't that what you just tried previously?
I have no idea dude, I thought I tried the exact same thing previously, but now it worked when I did it.
Maybe I didnt put them straight into /lib but in /lib/linux-x86/ and that didn't work.
rednoah wrote: 2.
Something doesn't work? Send the paths so I can confirm the problem myself.
Everything seems to work now, I'm just looking over the release group names as some of them are missing from the filebot list.
How long does it take for the list to be updated?
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Setting up "on finish" script - Transmission + Synology

Post by rednoah »

1-2 weeks.
:idea: Please read the FAQ and How to Request Help.
Cinder
Posts: 20
Joined: 17 Jun 2015, 19:22

Re: Setting up "on finish" script - Transmission + Synology

Post by Cinder »

Here's my postprocessing script:
filebot -script fn:amc --output "/volume1/TV Series" --log-file "/volume1/scripts/amc.log" --action hardlink --conflict override -non-strict --def music=n artwork=n "ut_dir=$TR_TORRENT_DIR/$TR_TORRENT_NAME" "ut_kind=multi" "ut_title=$TR_TORRENT_NAME" --def "seriesFormat=/volume1/TV Series/{n}/{n} {'Season '+s.pad(2)}/{n.space('.')}.{'S'+s.pad(2)}E{e.pad(2)}.{t.space('.')}{'.'+hpi}{'.'+source}{'.'+fn.match(/DD5.1|AC3|AAC2.0|DD2.0|MP2|MP3|DTS.5.1|DTSHD-MA|TrueHD|FLAC/)}{'.'+vc.replace('Microsoft', 'VC-1').replace('AVC', 'H.264')}{audio.FormatProfile =~ /MA Core/ ? '-HD.MA' : ''}{audio.FormatProfile =~ /ES/ ? '-ES' : ''}{audio.FormatProfile =~ /Pro/ ? '-Pro' : ''}{'-'+group}" --def "ut_label=TV" --def excludeList="/volume1/scripts/amc-excludeList.txt"
This script, if I understand correctly, is run on all finished torrents from transmission regardless if they're TV series, movies or music, --def "ut_label=TV" just tells filebot that it should look for tv shows right?
But it seems a waste that filebot should check all torrents on finish since I have a specific download folder where all my tv series (and nothing else) goes, is this somehow integrated into "ut_dir=$TR_TORRENT_DIR/$TR_TORRENT_NAME", or is there a way for me to tell filebot only to run this script "on finished downloads only going into this specific folder"
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Setting up "on finish" script - Transmission + Synology

Post by rednoah »

1.
Yes, --def ut_label=TV forces TV mode so the amc script will presume that all input is tv show episodes.

2.
It's your transmission-postprocess script that decides whether to call filebot or not. You'll have to add a condition for that in your shell script.

(you can probably make it work with --def ignore=pattern as well, but that's not very elegant for this use case)
:idea: Please read the FAQ and How to Request Help.
Cinder
Posts: 20
Joined: 17 Jun 2015, 19:22

Re: Setting up "on finish" script - Transmission + Synology

Post by Cinder »

Trying to create an if condition for the bash script.
Does the $TR_TORRENT_DIR match this format:

if [[ "$TR_TORRENT_DIR" == "/volume1/TV Series" ]];

does it need a / at the end of the path, or is the format entirely different from what I'm thinking here?

if [[ "$TR_TORRENT_DIR" == "/volume1/TV Series/" ]];

EDIT: Oh, and does bash script support wildcards in paths; /volume1/TV Series/*
Cinder
Posts: 20
Joined: 17 Jun 2015, 19:22

Re: Setting up "on finish" script - Transmission + Synology

Post by Cinder »

I'm currently not getting the bash script to run on torrent completion.

The only thing present in the script for testing is

#!/bin/bash
whoami > "volume1/scripts/filebot-verify.txt"


I've checked this with finishing torrents, and the script doesn't seem to run as the file is not created on torrent finished.

I have set up settings.json as per the guide, and I've set chmod +rx to the script above as well.
What else is there to check?

EDIT:
I set "chown transmission:root transmission-postprocess.sh" and now I have the file listed as
"-rwxr-xr-x 1 transmis root 86 Jun 26 22:08 transmission-postprocess.sh"

EDIT 2:
Nevermind, I got it to work by double checking all permissions and moving the .sh to the /transmission/var folder.
Post Reply