2022-02-21 22:28:32 +01:00
#!/bin/sh
2022-02-24 14:17:13 +01:00
# A simple script to extract a rar file inside a directory downloaded by Transmission.
# It uses environment variables passed by the transmission client to find and extract any rar files from a downloaded torrent into the folder they were found in.
# It will also try to copy *.srt/subtitle files if found.
2022-03-16 15:24:20 +01:00
#
# v1.1 - Added quotation marks to $TR_TORRENT_NAME to help with spaces
2022-02-24 14:17:13 +01:00
2022-02-21 22:28:32 +01:00
dest_folder = "/media/SpockVault/Downloads/Processing/"
2022-02-24 14:17:13 +01:00
# Script starts
2022-02-21 22:28:32 +01:00
echo " Post-processing $TR_TORRENT_NAME after finished download "
2022-03-16 15:24:20 +01:00
if [ -n " $( find $TR_TORRENT_DIR /" $TR_TORRENT_NAME " -name '*.rar' ) " ] ;
2022-02-21 22:28:32 +01:00
then
2022-02-24 14:17:13 +01:00
echo " Processing *.rar $TR_TORRENT_NAME to processing-dir "
2022-02-21 22:28:32 +01:00
touch $dest_folder /post_download_in_progress.md
2022-03-16 15:24:20 +01:00
find $TR_TORRENT_DIR /" $TR_TORRENT_NAME " -name "*.rar" -execdir unrar e -o- "{}" $dest_folder \;
2022-02-21 22:28:32 +01:00
rm $dest_folder /post_download_in_progress.md
2022-03-16 15:24:20 +01:00
elif [ -n " $( find $TR_TORRENT_DIR /" $TR_TORRENT_NAME " -iname '*.mkv' -or -iname '*.mp4' -or -iname '*.avi' ) " ]
2022-02-21 22:28:32 +01:00
then
touch $dest_folder /post_download_in_progress.md
2022-02-24 14:17:13 +01:00
echo " Processing video file from $TR_TORRENT_NAME to sickchill-dir "
2022-03-16 15:24:20 +01:00
find $TR_TORRENT_DIR /" $TR_TORRENT_NAME " -iname '*.mkv' -or -iname '*.mp4' -or -iname '*.avi' -or -iname '*.srt' | grep -iv sample | xargs cp -t $dest_folder
2022-02-21 22:28:32 +01:00
rm $dest_folder /post_download_in_progress.md
else
2022-02-24 14:17:13 +01:00
echo "No suitable files found, not doing anything.."
2022-02-21 22:28:32 +01:00
fi