From 59ea5749375265aba6974d7c0c9032e725f54444 Mon Sep 17 00:00:00 2001 From: Morten Date: Thu, 24 Feb 2022 14:17:13 +0100 Subject: [PATCH] Cleaned up, subtitle handling --- post_download.sh | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/post_download.sh b/post_download.sh index e7aad5a..b047a11 100644 --- a/post_download.sh +++ b/post_download.sh @@ -1,34 +1,25 @@ #!/bin/sh -#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. +# 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. + dest_folder="/media/SpockVault/Downloads/Processing/" +# Script starts echo "Post-processing $TR_TORRENT_NAME after finished download" -exit -logger "[transmission-postdownload] Post-processing $TR_TORRENT_NAME after finished download" if [ -n "$(find /$TR_TORRENT_DIR/$TR_TORRENT_NAME -name '*.rar')" ]; then - echo "Found *.rar, processing..." + echo "Processing *.rar $TR_TORRENT_NAME to processing-dir" touch $dest_folder/post_download_in_progress.md - logger "[transmission-postdownload] Processing *.rar $TR_TORRENT_NAME to processing-dir" - find /$TR_TORRENT_DIR/$TR_TORRENT_NAME -name "*.rar" -execdir unrar e -o- "{}" /media/SpockVault/Downloads/Processing/ \; + find /$TR_TORRENT_DIR/$TR_TORRENT_NAME -name "*.rar" -execdir unrar e -o- "{}" $dest_folder \; rm $dest_folder/post_download_in_progress.md -elif [ -n "$(find /$TR_TORRENT_DIR/$TR_TORRENT_NAME -iname '*.mkv' -o -iname '*.mp4' -or -iname '*.avi')" ] +elif [ -n "$(find /$TR_TORRENT_DIR/$TR_TORRENT_NAME -iname '*.mkv' -or -iname '*.mp4' -or -iname '*.avi')" ] then touch $dest_folder/post_download_in_progress.md - echo "Found video file, copying to sickchill-folder" - logger "[transmission-postdownload] Processing video file from $TR_TORRENT_NAME to sickchill-dir" - find /$TR_TORRENT_DIR/$TR_TORRENT_NAME -iname '*.mkv' -o -iname '*.mp4' -or -iname '*.avi' | grep -iv sample | xargs cp -t /media/SpockVault/Downloads/Processing/ + echo "Processing video file from $TR_TORRENT_NAME to sickchill-dir" + 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 rm $dest_folder/post_download_in_progress.md else - echo "No suitable files found" - logger "[transmission-postdownload] No suitable files found, doing nothing..." + echo "No suitable files found, not doing anything.." fi - - - - -#find /$TR_TORRENT_DIR/$TR_TORRENT_NAME -name "*.mkv" | grep -iv sample | xargs cp -t /media/SpockVault/Downloads/Processing/ -#find /$TR_TORRENT_DIR/$TR_TORRENT_NAME -name "*.avi" | grep -iv sample | xargs cp -t /media/SpockVault/Downloads/Processing/ -#find /$TR_TORRENT_DIR/$TR_TORRENT_NAME -name "*.mp4" | grep -iv sample | xargs cp -t /media/SpockVault/Downloads/Processing/ \ No newline at end of file