Encoding issue prevents renaming
Posted: 15 Sep 2014, 23:00
I'm triggering amc.groovy through a bash script ("script.sh") at the end of Transmission downloads.
Unfortunately, I get the following error (I've edited the actual paths):
Transmission sets two environment variables to communicate with the scripts it runs: TR_TORRENT_DIR and TR_TORRENT_NAME. If I set those variables manually before executing script.sh by hand, the renaming works.
If I add the parameter -Dfile.encoding=UTF-8 to filebot.sh, I get the following error :
Again, invoking script.sh by hand with TR_TORRENT_DIR and TR_TORRENT_NAME manully set works.
I've noticed two things when -Dfile.encoding=UTF-8 is set:
1) amc.groovy creates a destination folder that looks like this : /destination/accent_?_issue/path. See how the "é" became a "?". Then it triggers the above error.
2) If the proper destination/accent_é_issue/path folder exists before invoking script.sh, the script works even when called from Transmission.
So my guess is that filebot creates a destination folder with some wrong settings, replacing accentuated characters and such with "?". Then it tries to copy the file to the right destination folder, which fails... unless I had manually created that destination folder beforehand.
For reference (and in case this is what's causing the error), here is script.sh. The extra code is for dealing with logging and passing files as arguments during testing.
Unfortunately, I get the following error (I've edited the actual paths):
Code: Select all
[HARDLINK] Rename [/download/path] to [/destination/accent_é_issue/path]
java.nio.file.InvalidPathException: Malformed input or input contains unmappable chacraters: /destination/accent_é_issue/path
If I add the parameter -Dfile.encoding=UTF-8 to filebot.sh, I get the following error :
Code: Select all
[HARDLINK] Rename [/download/path] to [/destination/accent_é_issue/path]
[HARDLINK] Failed to rename [/download/path]
java.nio.file.NoSuchFileException: /destination/accent_é_issue/path -> /download/path
I've noticed two things when -Dfile.encoding=UTF-8 is set:
1) amc.groovy creates a destination folder that looks like this : /destination/accent_?_issue/path. See how the "é" became a "?". Then it triggers the above error.
2) If the proper destination/accent_é_issue/path folder exists before invoking script.sh, the script works even when called from Transmission.
So my guess is that filebot creates a destination folder with some wrong settings, replacing accentuated characters and such with "?". Then it tries to copy the file to the right destination folder, which fails... unless I had manually created that destination folder beforehand.
For reference (and in case this is what's causing the error), here is script.sh. The extra code is for dealing with logging and passing files as arguments during testing.
Code: Select all
# Log every execution (bad, rewrites every logfile)
exec > >(tee /path/to/script.log);
exec 2>&1;
DEFAULT_SCAN_DIR="/download/path";
if [[ -z $TR_TORRENT_DIR || -z $TR_TORRENT_NAME ]]; then
if [[ -z $1 ]]; then
FILE="$DEFAULT_SCAN_DIR";
SUBS="";
echo "script.sh: Scanning $DEFAULT_SCAN_DIR (default)";
echo "script.sh: Not downloading any subtitles, or you will get banned if the folder is full.";
else
FILE="$1";
SUBS="fr";
echo "script.sh: Scanning $FILE (given as argument)";
fi
else
FILE="$TR_TORRENT_DIR/$TR_TORRENT_NAME";
SUBS="fr";
echo "script.sh: Scanning $FILE (given by Transmission as env. variables)";
fi
filebot -script /path/to/amc.groovy\
--output "/destination/base/path"\
--log-file amc.log\
--action hardlink\
--conflict skip\
-non-strict\
--def clean=y\
--def music=n\
subtitles="$SUBS"\
--def plex="<plex IP>"\
artwork=n\
"ut_kind=single"\
"$FILE"