From 1fa1d72cb80a95f521c5f47c9e47a3fbf70103ab Mon Sep 17 00:00:00 2001 From: schumi2004 Date: Sat, 8 Dec 2012 23:11:54 +0100 Subject: [PATCH 01/19] Cosmetic and Typo changes --- .../9.0/bin/nzbget-postprocess.sh | 50 ++++++++++++++----- .../9.0/webui/nzbget-postprocess.conf | 8 +-- 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh b/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh index 8d680134..cb1eb1b9 100644 --- a/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh +++ b/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh @@ -164,6 +164,18 @@ if [ "$NZBPP_PARSTATUS" -eq 1 -o "$NZBPP_PARSTATUS" -eq 3 -o "$NZBPP_PARFAILED" echo "[WARNING] Post-Process: Par-check successful, but Par-repair disabled, exiting" else echo "[WARNING] Post-Process: Par-check failed, exiting" + # Send notifications to SickBeard or CouchPotato that Par-check failed + # Uncomment if SickBeard Branch is fixed + #if [ "$SickBeard" = "yes" -a "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -e "$SabToSickBeard" ]; then + # # Call SickBeard's postprocessing script + # echo "[INFO] Post-Process: Running SickBeard's postprocessing script to notify Par-check failed" + #$PythonCmd $SabToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "" "" "" "" "1" >/dev/null 2>&1 + #fi + if [ "$CouchPotato" = "yes" -a "$NZBPP_CATEGORY" = "$CouchPotatoCategory" -a -e "$nzbToCouchPotato" ]; then + # Call CouchPotato's postprocessing script + echo "[INFO] Post-Process: Running CouchPotato's postprocessing script to notify Par-check failed" + $PythonCmd $nzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "" "" "" "" "1" >/dev/null 2>&1 + fi fi exit $POSTPROCESS_ERROR fi @@ -226,6 +238,18 @@ if (ls *.rar >/dev/null 2>&1); then if (ls *.[pP][aA][rR]2 >/dev/null 2>&1); then echo "[INFO] Post-Process: Requesting par-repair" exit $POSTPROCESS_PARCHECK_ALL + # Send notifications to SickBeard or CouchPotato that unrar (second pass) failed + # Uncomment if SickBeard Branch is fixed + #if [ "$SickBeard" = "yes" -a "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -e "$SabToSickBeard" ]; then + # # Call SickBeard's postprocessing script + # echo "[INFO] Post-Process: Running SickBeard's postprocessing script to notify unrar (second pass) failed" + # $PythonCmd $SabToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "" "" "" "" "1">/dev/null 2>&1 + #fi + if [ "$CouchPotato" = "yes" -a "$NZBPP_CATEGORY" = "$CouchPotatoCategory" -a -e "$nzbToCouchPotato" ]; then + # Call CouchPotato's postprocessing script + echo "[INFO] Post-Process: Running CouchPotato's postprocessing script to notify unrar (second pass) failed" + $PythonCmd $nzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "" "" "" "" "1">/dev/null 2>&1 + fi fi exit $POSTPROCESS_ERROR fi @@ -282,9 +306,9 @@ fi # Clean up echo "[INFO] Post-Process: Cleaning up" chmod -R a+rw . -rm *.nzb >/dev/null 2>&1 -rm *.sfv >/dev/null 2>&1 -rm *.1 >/dev/null 2>&1 +# Clean up list, space seperated from GUI +rm $FileCleanUp >/dev/null 2>&1 +# Removed by default rm _brokenlog.txt >/dev/null 2>&1 if [ "$Unrared" -eq 1 ]; then # Delete par2-file only if there were files for unpacking. @@ -321,30 +345,30 @@ fi # Move categories to /share/yourdirectory and remove download destination directory if [ "$NZBPP_CATEGORY" = "$SickBeardCategory" ]; then - echo "[INFO] Post-Process: Moving TV shows to $TV_DL_DIR" - cp -R "$NZBPP_DIRECTORY" "$TV_DL_DIR" >/dev/null 2>&1 + echo "[INFO] Post-Process: Moving TV shows to $TvDownloadDir" + cp -R "$NZBPP_DIRECTORY" "$TvDownloadDir" >/dev/null 2>&1 if [ "$?" -ne 0 ]; then - echo "[ERROR] Post-Process: Moving to $TV_DL_DIR" + echo "[ERROR] Post-Process: Moving to $TvDownloadDir" exit $POSTPROCESS_ERROR else rm -fr * cd .. rmdir "$NZBPP_DIRECTORY" - NZBPP_DIRECTORY="$TV_DL_DIR" + NZBPP_DIRECTORY="$TvDownloadDir" fi fi if [ "$NZBPP_CATEGORY" = "$CouchPotatoCategory" ]; then - echo "[INFO] Post-Process: Moving Movies to $MOVIES_DL_DIR" - cp -R "$NZBPP_DIRECTORY" "$MOVIES_DL_DIR" >/dev/null 2>&1 + echo "[INFO] Post-Process: Moving Movies to $MoviesDownloadDir" + cp -R "$NZBPP_DIRECTORY" "$MoviesDownloadDir" >/dev/null 2>&1 if [ "$?" -ne 0 ]; then - echo "[ERROR] Post-Process: Moving to $MOVIES_DL_DIR" + echo "[ERROR] Post-Process: Moving to $MoviesDownloadDir" exit $POSTPROCESS_ERROR else rm -fr * cd .. rmdir "$NZBPP_DIRECTORY" - NZBPP_DIRECTORY="$MOVIES_DL_DIR" + NZBPP_DIRECTORY="$MoviesDownloadDir" fi fi @@ -355,13 +379,13 @@ fi if [ "$SickBeard" = "yes" -a "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -e "$NzbToSickBeard" ]; then # Call SickBeard's postprocessing script echo "[INFO] Post-Process: Running SickBeard's postprocessing script" - $PythonCmd $NzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" >/dev/null 2>&1 + $PythonCmd $NzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "" "" "" "" "0" >/dev/null 2>&1 fi if [ "$CouchPotato" = "yes" -a "$NZBPP_CATEGORY" = "$CouchPotatoCategory" -a -e "$NzbToCouchPotato" ]; then # Call CouchPotato's postprocessing script echo "[INFO] Post-Process: Running CouchPotato's postprocessing script" - $PythonCmd $NzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" >/dev/null 2>&1 + $PythonCmd $NzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "" "" "" "" "0" >/dev/null 2>&1 fi # Check if destination directory was set in postprocessing parameters diff --git a/nzbget-postprocessing-files/9.0/webui/nzbget-postprocess.conf b/nzbget-postprocessing-files/9.0/webui/nzbget-postprocess.conf index af6d01c2..61722981 100644 --- a/nzbget-postprocessing-files/9.0/webui/nzbget-postprocess.conf +++ b/nzbget-postprocessing-files/9.0/webui/nzbget-postprocess.conf @@ -36,15 +36,15 @@ PythonCmd=/usr/local/python/bin/python NzbToSickBeard=/usr/local/nzbget/var/nzbToSickBeard.py # Set the full path where completed movies should be placed -# before CouchPotato's Renamer is called -TV_DL_DIR=/usr/local/nzbget/complete/tv +# before SickBeard's Renamer is called +TvDownloadDir=/usr/local/nzbget/complete/tv # Set the full path to nzbToCouchpotato.py for Couchpotato's postprocessing NzbToCouchPotato=/usr/local/nzbget/var/nzbToCouchPotato.py # Set the full path where completed movies should be placed # before CouchPotato's Renamer is called -MOVIES_DL_DIR=/usr/local/nzbget/complete/movies +MoviesDownloadDir=/usr/local/nzbget/complete/movies ############################################################################## ### OPTIONS ### @@ -70,6 +70,8 @@ CouchPotato=yes # Category for Couchpotato's postprocessing. CouchPotatoCategory=movies +# Clean up list. (space seperated, default *.nzb *.sfv *.1) +FileCleanUp=*.nzb *.sfv *.1 ############################################################################## ### POSTPROCESSING-PARAMETERS ### From 9d791d778fbfc76cc1b778836ee0156a412e38de Mon Sep 17 00:00:00 2001 From: schumi2004 Date: Sun, 9 Dec 2012 21:12:14 +0100 Subject: [PATCH 02/19] Update nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh --- .../9.0/bin/nzbget-postprocess.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh b/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh index cb1eb1b9..e0e95a42 100644 --- a/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh +++ b/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh @@ -165,7 +165,7 @@ if [ "$NZBPP_PARSTATUS" -eq 1 -o "$NZBPP_PARSTATUS" -eq 3 -o "$NZBPP_PARFAILED" else echo "[WARNING] Post-Process: Par-check failed, exiting" # Send notifications to SickBeard or CouchPotato that Par-check failed - # Uncomment if SickBeard Branch is fixed + # Uncomment below if your using development branch from fork https://github.com/Tolstyak/Sick-Beard.git #if [ "$SickBeard" = "yes" -a "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -e "$SabToSickBeard" ]; then # # Call SickBeard's postprocessing script # echo "[INFO] Post-Process: Running SickBeard's postprocessing script to notify Par-check failed" @@ -239,7 +239,7 @@ if (ls *.rar >/dev/null 2>&1); then echo "[INFO] Post-Process: Requesting par-repair" exit $POSTPROCESS_PARCHECK_ALL # Send notifications to SickBeard or CouchPotato that unrar (second pass) failed - # Uncomment if SickBeard Branch is fixed + # Uncomment below if your using development branch from fork https://github.com/Tolstyak/Sick-Beard.git #if [ "$SickBeard" = "yes" -a "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -e "$SabToSickBeard" ]; then # # Call SickBeard's postprocessing script # echo "[INFO] Post-Process: Running SickBeard's postprocessing script to notify unrar (second pass) failed" @@ -379,7 +379,10 @@ fi if [ "$SickBeard" = "yes" -a "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -e "$NzbToSickBeard" ]; then # Call SickBeard's postprocessing script echo "[INFO] Post-Process: Running SickBeard's postprocessing script" - $PythonCmd $NzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "" "" "" "" "0" >/dev/null 2>&1 + # Uncomment below if your using development branch from fork https://github.com/Tolstyak/Sick-Beard.git + #$PythonCmd $NzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "" "" "" "" "0" >/dev/null 2>&1 + # If your using development branch from fork https://github.com/Tolstyak/Sick-Beard.git delete line below + $PythonCmd $NzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" >/dev/null 2>&1 fi if [ "$CouchPotato" = "yes" -a "$NZBPP_CATEGORY" = "$CouchPotatoCategory" -a -e "$NzbToCouchPotato" ]; then From acb8819bf9436fb9b98336215f23be36ebff3aec Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Mon, 10 Dec 2012 16:23:52 -0800 Subject: [PATCH 03/19] added failed handling from nzbget --- nzbToCouchPotato.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nzbToCouchPotato.py b/nzbToCouchPotato.py index 1fc4cd6b..6f53378d 100644 --- a/nzbToCouchPotato.py +++ b/nzbToCouchPotato.py @@ -17,14 +17,14 @@ if len(sys.argv) == 8: autoProcessMovie.process(sys.argv[1], sys.argv[2], sys.argv[7]) # NZBGet -elif len(sys.argv) == 3: +elif len(sys.argv) == 4: # NZBGet argv: # 1 The final directory of the job (full path) # 2 The original name of the NZB file -# From NZBGet only successful downloads are triggered so status is set to "0" +# 3 The status of the download: 0 == successful print "Script triggered from NZBGet, starting autoProcessMovie..." - autoProcessMovie.process(sys.argv[1], sys.argv[2], 0) + autoProcessMovie.process(sys.argv[1], sys.argv[2], sys.argv[3]) else: print "Invalid number of arguments received from client." From 5af37ee6c7f7f2c097df679281439dcee9a0f37e Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Mon, 10 Dec 2012 16:24:42 -0800 Subject: [PATCH 04/19] added failed download handling from nzbget --- nzbToSickBeard.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nzbToSickBeard.py b/nzbToSickBeard.py index a2cb2d7b..29cd4ec4 100644 --- a/nzbToSickBeard.py +++ b/nzbToSickBeard.py @@ -39,14 +39,14 @@ if len(sys.argv) == 8: autoProcessTV.processEpisode(sys.argv[1], sys.argv[2], sys.argv[7]) # NZBGet -elif len(sys.argv) == 3: +elif len(sys.argv) == 4: # NZBGet argv: # 1 The final directory of the job (full path) # 2 The original name of the NZB file -# From NZBGet only successful downloads are triggered so status is set to "0" +# 3 The status of the download: 0 == successful print "Script triggered from NZBGet, starting autoProcessTV..." - autoProcessTV.processEpisode(sys.argv[1], sys.argv[2], 0) + autoProcessTV.processEpisode(sys.argv[1], sys.argv[2], sys.argv[3]) else: print "Invalid number of arguments received from client." From 5d42efb7474e6fcca283a9fe79e30fe96feb836e Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Mon, 10 Dec 2012 16:28:30 -0800 Subject: [PATCH 05/19] set to only send 4 arguments to postprocess script --- .../9.0/bin/nzbget-postprocess.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh b/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh index e0e95a42..b9ecad25 100644 --- a/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh +++ b/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh @@ -169,12 +169,12 @@ if [ "$NZBPP_PARSTATUS" -eq 1 -o "$NZBPP_PARSTATUS" -eq 3 -o "$NZBPP_PARFAILED" #if [ "$SickBeard" = "yes" -a "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -e "$SabToSickBeard" ]; then # # Call SickBeard's postprocessing script # echo "[INFO] Post-Process: Running SickBeard's postprocessing script to notify Par-check failed" - #$PythonCmd $SabToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "" "" "" "" "1" >/dev/null 2>&1 + #$PythonCmd $SabToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "1" >/dev/null 2>&1 #fi if [ "$CouchPotato" = "yes" -a "$NZBPP_CATEGORY" = "$CouchPotatoCategory" -a -e "$nzbToCouchPotato" ]; then # Call CouchPotato's postprocessing script echo "[INFO] Post-Process: Running CouchPotato's postprocessing script to notify Par-check failed" - $PythonCmd $nzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "" "" "" "" "1" >/dev/null 2>&1 + $PythonCmd $nzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "1" >/dev/null 2>&1 fi fi exit $POSTPROCESS_ERROR @@ -243,12 +243,12 @@ if (ls *.rar >/dev/null 2>&1); then #if [ "$SickBeard" = "yes" -a "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -e "$SabToSickBeard" ]; then # # Call SickBeard's postprocessing script # echo "[INFO] Post-Process: Running SickBeard's postprocessing script to notify unrar (second pass) failed" - # $PythonCmd $SabToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "" "" "" "" "1">/dev/null 2>&1 + # $PythonCmd $SabToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "1">/dev/null 2>&1 #fi if [ "$CouchPotato" = "yes" -a "$NZBPP_CATEGORY" = "$CouchPotatoCategory" -a -e "$nzbToCouchPotato" ]; then # Call CouchPotato's postprocessing script echo "[INFO] Post-Process: Running CouchPotato's postprocessing script to notify unrar (second pass) failed" - $PythonCmd $nzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "" "" "" "" "1">/dev/null 2>&1 + $PythonCmd $nzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "1">/dev/null 2>&1 fi fi exit $POSTPROCESS_ERROR @@ -380,7 +380,7 @@ if [ "$SickBeard" = "yes" -a "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -e "$Nz # Call SickBeard's postprocessing script echo "[INFO] Post-Process: Running SickBeard's postprocessing script" # Uncomment below if your using development branch from fork https://github.com/Tolstyak/Sick-Beard.git - #$PythonCmd $NzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "" "" "" "" "0" >/dev/null 2>&1 + #$PythonCmd $NzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "0" >/dev/null 2>&1 # If your using development branch from fork https://github.com/Tolstyak/Sick-Beard.git delete line below $PythonCmd $NzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" >/dev/null 2>&1 fi @@ -388,7 +388,7 @@ fi if [ "$CouchPotato" = "yes" -a "$NZBPP_CATEGORY" = "$CouchPotatoCategory" -a -e "$NzbToCouchPotato" ]; then # Call CouchPotato's postprocessing script echo "[INFO] Post-Process: Running CouchPotato's postprocessing script" - $PythonCmd $NzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "" "" "" "" "0" >/dev/null 2>&1 + $PythonCmd $NzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "0" >/dev/null 2>&1 fi # Check if destination directory was set in postprocessing parameters From d2f70ed99e109c5f5f3d3de5a2d60b017a4ddfdf Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Mon, 10 Dec 2012 16:54:49 -0800 Subject: [PATCH 06/19] set failed handling for sickbeard to be on --- .../9.0/bin/nzbget-postprocess.sh | 33 ++++++++----------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh b/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh index b9ecad25..a74873ac 100644 --- a/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh +++ b/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh @@ -165,12 +165,11 @@ if [ "$NZBPP_PARSTATUS" -eq 1 -o "$NZBPP_PARSTATUS" -eq 3 -o "$NZBPP_PARFAILED" else echo "[WARNING] Post-Process: Par-check failed, exiting" # Send notifications to SickBeard or CouchPotato that Par-check failed - # Uncomment below if your using development branch from fork https://github.com/Tolstyak/Sick-Beard.git - #if [ "$SickBeard" = "yes" -a "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -e "$SabToSickBeard" ]; then - # # Call SickBeard's postprocessing script - # echo "[INFO] Post-Process: Running SickBeard's postprocessing script to notify Par-check failed" - #$PythonCmd $SabToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "1" >/dev/null 2>&1 - #fi + if [ "$SickBeard" = "yes" -a "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -e "$nzbToSickBeard" ]; then + # Call SickBeard's postprocessing script + echo "[INFO] Post-Process: Running SickBeard's postprocessing script to notify Par-check failed" + $PythonCmd $nzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "1" >/dev/null 2>&1 + fi if [ "$CouchPotato" = "yes" -a "$NZBPP_CATEGORY" = "$CouchPotatoCategory" -a -e "$nzbToCouchPotato" ]; then # Call CouchPotato's postprocessing script echo "[INFO] Post-Process: Running CouchPotato's postprocessing script to notify Par-check failed" @@ -238,12 +237,11 @@ if (ls *.rar >/dev/null 2>&1); then if (ls *.[pP][aA][rR]2 >/dev/null 2>&1); then echo "[INFO] Post-Process: Requesting par-repair" exit $POSTPROCESS_PARCHECK_ALL - # Send notifications to SickBeard or CouchPotato that unrar (second pass) failed - # Uncomment below if your using development branch from fork https://github.com/Tolstyak/Sick-Beard.git - #if [ "$SickBeard" = "yes" -a "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -e "$SabToSickBeard" ]; then - # # Call SickBeard's postprocessing script - # echo "[INFO] Post-Process: Running SickBeard's postprocessing script to notify unrar (second pass) failed" - # $PythonCmd $SabToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "1">/dev/null 2>&1 + # Send notifications to SickBeard or CouchPotato that unrar (second pass) failed + if [ "$SickBeard" = "yes" -a "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -e "$nzbToSickBeard" ]; then + # Call SickBeard's postprocessing script + echo "[INFO] Post-Process: Running SickBeard's postprocessing script to notify unrar (second pass) failed" + $PythonCmd $nzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "1">/dev/null 2>&1 #fi if [ "$CouchPotato" = "yes" -a "$NZBPP_CATEGORY" = "$CouchPotatoCategory" -a -e "$nzbToCouchPotato" ]; then # Call CouchPotato's postprocessing script @@ -376,19 +374,16 @@ fi ### END CUSTOMIZATIONS ### ########################## -if [ "$SickBeard" = "yes" -a "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -e "$NzbToSickBeard" ]; then +if [ "$SickBeard" = "yes" -a "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -e "$nzbToSickBeard" ]; then # Call SickBeard's postprocessing script echo "[INFO] Post-Process: Running SickBeard's postprocessing script" - # Uncomment below if your using development branch from fork https://github.com/Tolstyak/Sick-Beard.git - #$PythonCmd $NzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "0" >/dev/null 2>&1 - # If your using development branch from fork https://github.com/Tolstyak/Sick-Beard.git delete line below - $PythonCmd $NzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" >/dev/null 2>&1 + $PythonCmd $nzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "0" >/dev/null 2>&1 fi -if [ "$CouchPotato" = "yes" -a "$NZBPP_CATEGORY" = "$CouchPotatoCategory" -a -e "$NzbToCouchPotato" ]; then +if [ "$CouchPotato" = "yes" -a "$NZBPP_CATEGORY" = "$CouchPotatoCategory" -a -e "$nzbToCouchPotato" ]; then # Call CouchPotato's postprocessing script echo "[INFO] Post-Process: Running CouchPotato's postprocessing script" - $PythonCmd $NzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "0" >/dev/null 2>&1 + $PythonCmd $nzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "0" >/dev/null 2>&1 fi # Check if destination directory was set in postprocessing parameters From 113dab58f3f3c5859a894f2f5f0b832f5bdbcb0d Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Mon, 10 Dec 2012 16:57:48 -0800 Subject: [PATCH 07/19] capitalize "N" in paramter NzbTo* --- .../9.0/bin/nzbget-postprocess.sh | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh b/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh index a74873ac..27bb6fc9 100644 --- a/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh +++ b/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh @@ -165,15 +165,15 @@ if [ "$NZBPP_PARSTATUS" -eq 1 -o "$NZBPP_PARSTATUS" -eq 3 -o "$NZBPP_PARFAILED" else echo "[WARNING] Post-Process: Par-check failed, exiting" # Send notifications to SickBeard or CouchPotato that Par-check failed - if [ "$SickBeard" = "yes" -a "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -e "$nzbToSickBeard" ]; then + if [ "$SickBeard" = "yes" -a "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -e "$NzbToSickBeard" ]; then # Call SickBeard's postprocessing script echo "[INFO] Post-Process: Running SickBeard's postprocessing script to notify Par-check failed" - $PythonCmd $nzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "1" >/dev/null 2>&1 + $PythonCmd $NzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "1" >/dev/null 2>&1 fi - if [ "$CouchPotato" = "yes" -a "$NZBPP_CATEGORY" = "$CouchPotatoCategory" -a -e "$nzbToCouchPotato" ]; then + if [ "$CouchPotato" = "yes" -a "$NZBPP_CATEGORY" = "$CouchPotatoCategory" -a -e "$NzbToCouchPotato" ]; then # Call CouchPotato's postprocessing script echo "[INFO] Post-Process: Running CouchPotato's postprocessing script to notify Par-check failed" - $PythonCmd $nzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "1" >/dev/null 2>&1 + $PythonCmd $NzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "1" >/dev/null 2>&1 fi fi exit $POSTPROCESS_ERROR @@ -238,15 +238,15 @@ if (ls *.rar >/dev/null 2>&1); then echo "[INFO] Post-Process: Requesting par-repair" exit $POSTPROCESS_PARCHECK_ALL # Send notifications to SickBeard or CouchPotato that unrar (second pass) failed - if [ "$SickBeard" = "yes" -a "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -e "$nzbToSickBeard" ]; then + if [ "$SickBeard" = "yes" -a "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -e "$NzbToSickBeard" ]; then # Call SickBeard's postprocessing script echo "[INFO] Post-Process: Running SickBeard's postprocessing script to notify unrar (second pass) failed" - $PythonCmd $nzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "1">/dev/null 2>&1 + $PythonCmd $NzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "1">/dev/null 2>&1 #fi - if [ "$CouchPotato" = "yes" -a "$NZBPP_CATEGORY" = "$CouchPotatoCategory" -a -e "$nzbToCouchPotato" ]; then + if [ "$CouchPotato" = "yes" -a "$NZBPP_CATEGORY" = "$CouchPotatoCategory" -a -e "$NzbToCouchPotato" ]; then # Call CouchPotato's postprocessing script echo "[INFO] Post-Process: Running CouchPotato's postprocessing script to notify unrar (second pass) failed" - $PythonCmd $nzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "1">/dev/null 2>&1 + $PythonCmd $NzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "1">/dev/null 2>&1 fi fi exit $POSTPROCESS_ERROR @@ -374,16 +374,16 @@ fi ### END CUSTOMIZATIONS ### ########################## -if [ "$SickBeard" = "yes" -a "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -e "$nzbToSickBeard" ]; then +if [ "$SickBeard" = "yes" -a "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -e "$NzbToSickBeard" ]; then # Call SickBeard's postprocessing script echo "[INFO] Post-Process: Running SickBeard's postprocessing script" - $PythonCmd $nzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "0" >/dev/null 2>&1 + $PythonCmd $NzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "0" >/dev/null 2>&1 fi -if [ "$CouchPotato" = "yes" -a "$NZBPP_CATEGORY" = "$CouchPotatoCategory" -a -e "$nzbToCouchPotato" ]; then +if [ "$CouchPotato" = "yes" -a "$NZBPP_CATEGORY" = "$CouchPotatoCategory" -a -e "$NzbToCouchPotato" ]; then # Call CouchPotato's postprocessing script echo "[INFO] Post-Process: Running CouchPotato's postprocessing script" - $PythonCmd $nzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "0" >/dev/null 2>&1 + $PythonCmd $NzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "0" >/dev/null 2>&1 fi # Check if destination directory was set in postprocessing parameters From f44273484d3628fc72188bda65bc8bbe6c90fe7e Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Mon, 10 Dec 2012 17:20:08 -0800 Subject: [PATCH 08/19] added failed handling pass through must specify new parameter "failed_fork" = 1 when using that version of SickBeard. --- autoProcessTV.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/autoProcessTV.py b/autoProcessTV.py index acfca15a..cbb26939 100644 --- a/autoProcessTV.py +++ b/autoProcessTV.py @@ -44,10 +44,6 @@ class AuthURLOpener(urllib.FancyURLopener): def processEpisode(dirName, nzbName=None, status=0): status = int(status) - if status > 0: - print "the download failed. nothing to process" - sys.exit() - config = ConfigParser.ConfigParser() configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessTV.cfg") print "Loading config from", configFilename @@ -77,14 +73,30 @@ def processEpisode(dirName, nzbName=None, status=0): web_root = config.get("SickBeard", "web_root") except ConfigParser.NoOptionError: web_root = "" + + try: + failed_fork = int(config.get("SickBeard", "failed_fork")) + except (ConfigParser.NoOptionError, ValueError): + failed_fork = 0 params = {} params['quiet'] = 1 - params['dir'] = dirName - if nzbName != None: - params['nzbName'] = nzbName + #this is our default behaviour to work with the standard Master branch of SickBeard + if failed_fork == 0: + params['dir'] = dirName + if nzbName != None: + params['nzbName'] = nzbName + # if you have specified you are using development branch from fork https://github.com/Tolstyak/Sick-Beard.git + else: + params['dirName'] = dirName + if nzbName != None: + params['nzbName'] = nzbName + if status == 0: + params['failed'] = False + else: + params['failed'] = True myOpener = AuthURLOpener(username, password) From 2dc3bc0370b7e910e33a8da883f56441a1958617 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Mon, 10 Dec 2012 17:23:27 -0800 Subject: [PATCH 09/19] added "failed_fork" parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit set to 1 if using the development branch from fork https://github.com/Tolstyak/Sick-Beard.git --- autoProcessTV.cfg.sample | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autoProcessTV.cfg.sample b/autoProcessTV.cfg.sample index 15dc900c..6fd4ba69 100644 --- a/autoProcessTV.cfg.sample +++ b/autoProcessTV.cfg.sample @@ -4,4 +4,5 @@ port=8081 username= password= web_root= -ssl=0 \ No newline at end of file +ssl=0 +failed_fork=0 \ No newline at end of file From 65b20faf067eae6e94292292700bbcccb4c64f68 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Mon, 10 Dec 2012 17:28:29 -0800 Subject: [PATCH 10/19] Added SickBeard Failed Option --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index bda762d6..f9b2cefc 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,9 @@ thorli's Synology DS211j was too weak to provide decent downloads rates with SAB The renamer of CouchPotatoServer caused broken downloads by interfering with NZBGet while it was still unpacking the files. Hence the solution was thorli's version of sabToCouchPotato which has now been named "nzbToCouchPotato". +Failed download handling for SickBeard is available by using the development branch from fork [SickBeard-failed](https://github.com/Tolstyak/Sick-Beard.git "SickBeard-failed") +To use this feature, in autoProcessTV.cfg set the parameter "failed_fork=1". Default is 0 and will work with standard version of SickBeard and just ignores failed downloads. + Installation ------------ ### General From cf7aa2b062e35cfc851bb1868d2d84466c7d21c6 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Mon, 10 Dec 2012 17:37:32 -0800 Subject: [PATCH 11/19] Exit for standard branch when status is failed. --- autoProcessTV.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/autoProcessTV.py b/autoProcessTV.py index cbb26939..b696fbf0 100644 --- a/autoProcessTV.py +++ b/autoProcessTV.py @@ -83,11 +83,15 @@ def processEpisode(dirName, nzbName=None, status=0): params['quiet'] = 1 - #this is our default behaviour to work with the standard Master branch of SickBeard + # this is our default behaviour to work with the standard Master branch of SickBeard if failed_fork == 0: params['dir'] = dirName if nzbName != None: params['nzbName'] = nzbName + # the standard Master bamch of SickBeard cannot process failed downloads. So Exit here. + if status != 0: + print "the download failed. nothing to process" + sys.exit() # if you have specified you are using development branch from fork https://github.com/Tolstyak/Sick-Beard.git else: params['dirName'] = dirName From ed1bde9a83d590c4e36aabcc48a15b9d50fbe4b5 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Mon, 10 Dec 2012 17:45:56 -0800 Subject: [PATCH 12/19] V3.2 --- autoProcessMovie.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoProcessMovie.py b/autoProcessMovie.py index 48d7fba3..b6c7d4f7 100644 --- a/autoProcessMovie.py +++ b/autoProcessMovie.py @@ -30,7 +30,7 @@ def process(dirName, nzbName=None, status=0): status = int(status) config = ConfigParser.ConfigParser() configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMovie.cfg") - print "autoProcessMovie v 3.1" + print "autoProcessMovie v 3.2" print "Loading config from", configFilename if not os.path.isfile(configFilename): From 699b7ae498bdf1f07bdd3402d0d6c51e0a01e9ab Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Mon, 10 Dec 2012 17:48:33 -0800 Subject: [PATCH 13/19] V3.2 --- changelog.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/changelog.txt b/changelog.txt index b1a24521..fa23ec09 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,10 @@ Change_LOG / History +V3.2 11/12/2012 + +Added failed handling from NZBGet. Thanks to schumi2004. +Also added support for the "failed download" development branch of SickBeard from https://github.com/Tolstyak/Sick-Beard.git + V3.1 02/12/2012 added conversion to ensure the status passed to the autoProcessTV and autoProcessMovie is always handled as an integer. From d4a35659a378b16761be9f717b4dda0e3043d80e Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Mon, 10 Dec 2012 18:39:32 -0800 Subject: [PATCH 14/19] Update nzbGet 0.8.0 to function same as 9.0 --- nzbget-postprocessing-files/0.8.0/postprocess.conf | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nzbget-postprocessing-files/0.8.0/postprocess.conf b/nzbget-postprocessing-files/0.8.0/postprocess.conf index e6111267..8d9c5e44 100644 --- a/nzbget-postprocessing-files/0.8.0/postprocess.conf +++ b/nzbget-postprocessing-files/0.8.0/postprocess.conf @@ -11,15 +11,15 @@ PythonCmd=/usr/local/python/bin/python NzbToSickBeard=/usr/local/nzbget/var/nzbToSickBeard.py # Set the full path where completed movies should be placed -# before CouchPotato's Renamer is called -TV_DL_DIR=/usr/local/nzbget/complete/tv +# before SickBeard's Renamer is called +TvDownloadDir=/usr/local/nzbget/complete/tv # Set the full path to nzbToCouchpotato.py for Couchpotato's postprocessing NzbToCouchPotato=/usr/local/nzbget/var/nzbToCouchPotato.py # Set the full path where completed movies should be placed # before CouchPotato's Renamer is called -MOVIES_DL_DIR=/usr/local/nzbget/complete/movies +MoviesDownloadDir=/usr/local/nzbget/complete/movies ############################################################################## @@ -49,6 +49,8 @@ CouchPotato=yes # Category for Couchpotato's postprocessing (eg. movies) CouchPotatoCategory=movies +# Clean up list. (space seperated, default *.nzb *.sfv *.1) +FileCleanUp=*.nzb *.sfv *.1 ############################################################################## ### POSTPROCESSING-PARAMETERS ### From 17c4adbcf6b6208dea327ae2e81fde15ba11c065 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Mon, 10 Dec 2012 18:52:32 -0800 Subject: [PATCH 15/19] Updated to same functionality as 9.0 --- .../0.8.0/postprocess.sh | 48 ++++++++++++++----- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/nzbget-postprocessing-files/0.8.0/postprocess.sh b/nzbget-postprocessing-files/0.8.0/postprocess.sh index 67a37127..e03a23f8 100644 --- a/nzbget-postprocessing-files/0.8.0/postprocess.sh +++ b/nzbget-postprocessing-files/0.8.0/postprocess.sh @@ -164,6 +164,17 @@ if [ "$NZBPP_PARSTATUS" -eq 1 -o "$NZBPP_PARSTATUS" -eq 3 -o "$NZBPP_PARFAILED" echo "[WARNING] Post-Process: Par-check successful, but Par-repair disabled, exiting" else echo "[WARNING] Post-Process: Par-check failed, exiting" + # Send notifications to SickBeard or CouchPotato that Par-check failed + if [ "$SickBeard" = "yes" -a "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -e "$NzbToSickBeard" ]; then + # Call SickBeard's postprocessing script + echo "[INFO] Post-Process: Running SickBeard's postprocessing script to notify Par-check failed" + $PythonCmd $NzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "1" >/dev/null 2>&1 + fi + if [ "$CouchPotato" = "yes" -a "$NZBPP_CATEGORY" = "$CouchPotatoCategory" -a -e "$NzbToCouchPotato" ]; then + # Call CouchPotato's postprocessing script + echo "[INFO] Post-Process: Running CouchPotato's postprocessing script to notify Par-check failed" + $PythonCmd $NzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "1" >/dev/null 2>&1 + fi fi exit $POSTPROCESS_ERROR fi @@ -226,6 +237,17 @@ if (ls *.rar >/dev/null 2>&1); then if (ls *.[pP][aA][rR]2 >/dev/null 2>&1); then echo "[INFO] Post-Process: Requesting par-repair" exit $POSTPROCESS_PARCHECK_ALL + # Send notifications to SickBeard or CouchPotato that unrar (second pass) failed + if [ "$SickBeard" = "yes" -a "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -e "$NzbToSickBeard" ]; then + # Call SickBeard's postprocessing script + echo "[INFO] Post-Process: Running SickBeard's postprocessing script to notify unrar (second pass) failed" + $PythonCmd $NzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "1">/dev/null 2>&1 + fi + if [ "$CouchPotato" = "yes" -a "$NZBPP_CATEGORY" = "$CouchPotatoCategory" -a -e "$NzbToCouchPotato" ]; then + # Call CouchPotato's postprocessing script + echo "[INFO] Post-Process: Running CouchPotato's postprocessing script to notify unrar (second pass) failed" + $PythonCmd $NzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "1">/dev/null 2>&1 + fi fi exit $POSTPROCESS_ERROR fi @@ -282,9 +304,9 @@ fi # Clean up echo "[INFO] Post-Process: Cleaning up" chmod -R a+rw . -rm *.nzb >/dev/null 2>&1 -rm *.sfv >/dev/null 2>&1 -rm *.1 >/dev/null 2>&1 +# Clean up list, space seperated from GUI +rm $FileCleanUp >/dev/null 2>&1 +# Removed by default rm _brokenlog.txt >/dev/null 2>&1 if [ "$Unrared" -eq 1 ]; then # Delete par2-file only if there were files for unpacking. @@ -321,30 +343,30 @@ fi # Move categories to /share/yourdirectory and remove download destination directory if [ "$NZBPP_CATEGORY" = "$SickBeardCategory" ]; then - echo "[INFO] Post-Process: Moving TV shows to $TV_DL_DIR" - cp -R "$NZBPP_DIRECTORY" "$TV_DL_DIR" >/dev/null 2>&1 + echo "[INFO] Post-Process: Moving TV shows to $TvDownloadDir" + cp -R "$NZBPP_DIRECTORY" "$TvDownloadDir" >/dev/null 2>&1 if [ "$?" -ne 0 ]; then - echo "[ERROR] Post-Process: Moving to $TV_DL_DIR" + echo "[ERROR] Post-Process: Moving to $TvDownloadDir" exit $POSTPROCESS_ERROR else rm -fr * cd .. rmdir "$NZBPP_DIRECTORY" - NZBPP_DIRECTORY="$TV_DL_DIR" + NZBPP_DIRECTORY="$TvDownloadDir" fi fi if [ "$NZBPP_CATEGORY" = "$CouchPotatoCategory" ]; then - echo "[INFO] Post-Process: Moving Movies to $MOVIES_DL_DIR" - cp -R "$NZBPP_DIRECTORY" "$MOVIES_DL_DIR" >/dev/null 2>&1 + echo "[INFO] Post-Process: Moving Movies to $MoviesDownloadDir" + cp -R "$NZBPP_DIRECTORY" "$MoviesDownloadDir" >/dev/null 2>&1 if [ "$?" -ne 0 ]; then - echo "[ERROR] Post-Process: Moving to $MOVIES_DL_DIR" + echo "[ERROR] Post-Process: Moving to $MoviesDownloadDir" exit $POSTPROCESS_ERROR else rm -fr * cd .. rmdir "$NZBPP_DIRECTORY" - NZBPP_DIRECTORY="$MOVIES_DL_DIR" + NZBPP_DIRECTORY="$MoviesDownloadDir" fi fi @@ -355,13 +377,13 @@ fi if [ "$SickBeard" = "yes" -a "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -e "$NzbToSickBeard" ]; then # Call SickBeard's postprocessing script echo "[INFO] Post-Process: Running SickBeard's postprocessing script" - $PythonCmd $NzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" >/dev/null 2>&1 + $PythonCmd $NzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "0" >/dev/null 2>&1 fi if [ "$CouchPotato" = "yes" -a "$NZBPP_CATEGORY" = "$CouchPotatoCategory" -a -e "$NzbToCouchPotato" ]; then # Call CouchPotato's postprocessing script echo "[INFO] Post-Process: Running CouchPotato's postprocessing script" - $PythonCmd $NzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" >/dev/null 2>&1 + $PythonCmd $NzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "0" >/dev/null 2>&1 fi # Check if destination directory was set in postprocessing parameters From d0a45c1a8f6885d73d88f6bd4e8f41b4087c591e Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Mon, 10 Dec 2012 18:53:34 -0800 Subject: [PATCH 16/19] Removed unwanted # --- nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh b/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh index 27bb6fc9..41cc5867 100644 --- a/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh +++ b/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh @@ -242,7 +242,7 @@ if (ls *.rar >/dev/null 2>&1); then # Call SickBeard's postprocessing script echo "[INFO] Post-Process: Running SickBeard's postprocessing script to notify unrar (second pass) failed" $PythonCmd $NzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "1">/dev/null 2>&1 - #fi + fi if [ "$CouchPotato" = "yes" -a "$NZBPP_CATEGORY" = "$CouchPotatoCategory" -a -e "$NzbToCouchPotato" ]; then # Call CouchPotato's postprocessing script echo "[INFO] Post-Process: Running CouchPotato's postprocessing script to notify unrar (second pass) failed" From 5865744a683f88fe655ee64561dea8aac2085be3 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Tue, 11 Dec 2012 14:38:00 -0800 Subject: [PATCH 17/19] Don't use custom dir if not passed in conf --- nzbget-postprocessing-files/0.8.0/postprocess.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nzbget-postprocessing-files/0.8.0/postprocess.sh b/nzbget-postprocessing-files/0.8.0/postprocess.sh index e03a23f8..845863d4 100644 --- a/nzbget-postprocessing-files/0.8.0/postprocess.sh +++ b/nzbget-postprocessing-files/0.8.0/postprocess.sh @@ -342,7 +342,8 @@ fi ############################ # Move categories to /share/yourdirectory and remove download destination directory -if [ "$NZBPP_CATEGORY" = "$SickBeardCategory" ]; then +# Test for category and ensure the passed directory exists as a directory. +if [ "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -d "$TvDownloadDir" ]; then echo "[INFO] Post-Process: Moving TV shows to $TvDownloadDir" cp -R "$NZBPP_DIRECTORY" "$TvDownloadDir" >/dev/null 2>&1 if [ "$?" -ne 0 ]; then @@ -355,8 +356,8 @@ if [ "$NZBPP_CATEGORY" = "$SickBeardCategory" ]; then NZBPP_DIRECTORY="$TvDownloadDir" fi fi - -if [ "$NZBPP_CATEGORY" = "$CouchPotatoCategory" ]; then +# Test for category and ensure the passed directory exists as a directory. +if [ "$NZBPP_CATEGORY" = "$CouchPotatoCategory" -a -d "$MoviesDownloadDir' ]; then echo "[INFO] Post-Process: Moving Movies to $MoviesDownloadDir" cp -R "$NZBPP_DIRECTORY" "$MoviesDownloadDir" >/dev/null 2>&1 if [ "$?" -ne 0 ]; then From 7ab69f77896aea30879178ef612c44542246b52f Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Tue, 11 Dec 2012 14:41:03 -0800 Subject: [PATCH 18/19] Don't use custom dir if not passed in conf --- nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh b/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh index 41cc5867..1435df9f 100644 --- a/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh +++ b/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh @@ -342,7 +342,8 @@ fi ############################ # Move categories to /share/yourdirectory and remove download destination directory -if [ "$NZBPP_CATEGORY" = "$SickBeardCategory" ]; then +# Test for category and ensure the passed directory exists as a directory. +if [ "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -d "$TvDownloadDir" ]; then echo "[INFO] Post-Process: Moving TV shows to $TvDownloadDir" cp -R "$NZBPP_DIRECTORY" "$TvDownloadDir" >/dev/null 2>&1 if [ "$?" -ne 0 ]; then @@ -355,8 +356,8 @@ if [ "$NZBPP_CATEGORY" = "$SickBeardCategory" ]; then NZBPP_DIRECTORY="$TvDownloadDir" fi fi - -if [ "$NZBPP_CATEGORY" = "$CouchPotatoCategory" ]; then +# Test for category and ensure the passed directory exists as a directory. +if [ "$NZBPP_CATEGORY" = "$CouchPotatoCategory" -a -d "$MoviesDownloadDir" ]; then echo "[INFO] Post-Process: Moving Movies to $MoviesDownloadDir" cp -R "$NZBPP_DIRECTORY" "$MoviesDownloadDir" >/dev/null 2>&1 if [ "$?" -ne 0 ]; then From 4f4d07fcaea9eb7165704aadde0731b830f58891 Mon Sep 17 00:00:00 2001 From: Jurgen S Date: Thu, 13 Dec 2012 00:31:35 +0100 Subject: [PATCH 19/19] added postprocess-failed.sh for handling failed downloads based on origingal postprocess.sh, does not include support for additional directories, only for testing --- .../0.8.0/postprocess-failed.sh | 372 ++++++++++++++++++ .../0.8.0/postprocess.sh | 2 +- 2 files changed, 373 insertions(+), 1 deletion(-) create mode 100644 nzbget-postprocessing-files/0.8.0/postprocess-failed.sh diff --git a/nzbget-postprocessing-files/0.8.0/postprocess-failed.sh b/nzbget-postprocessing-files/0.8.0/postprocess-failed.sh new file mode 100644 index 00000000..2bdd0889 --- /dev/null +++ b/nzbget-postprocessing-files/0.8.0/postprocess-failed.sh @@ -0,0 +1,372 @@ +#!/bin/sh +# +# Example postprocessing script for NZBGet +# +# Copyright (C) 2008 Peter Roubos +# Copyright (C) 2008 Otmar Werner +# Copyright (C) 2008-2009 Andrei Prygounkov +# Copyright (C) 2012 Antoine Bertin +# Copyright (C) 2012 Jürgen Seif +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# + +####################### Usage instructions ####################### +# o Script will unrar downloaded rar files, join ts-files and rename img-files +# to iso. +# +# o To use this script with nzbget set the option "PostProcess" in +# nzbget configuration file to point to this script file. E.g.: +# PostProcess=/home/user/nzbget/nzbget-postprocess.sh +# +# o The script needs a configuration file. An example configuration file +# is provided in file "postprocess-example.conf". Put the configuration file +# into the directory where nzbget's configuration file (nzbget.conf) or where +# this script itself is located. Then edit the configuration file in any +# text editor to adjust the settings. +# +# o You can also edit the script's configuration via web-interface (requires +# NZBGetWeb 1.4 or later). Set the options "PostProcessConfigFile" and +# "PostProcessConfigTemplate" to point to "postprocess-example.conf" +# (including full path). The both options are under the section +# "CONFIGURATION OF POSTPROCESSING-SCRIPT" in NZBGetWeb. +# +# o There are few options, which can be ajdusted for each nzb-file +# individually. To view/edit them in web-interface click on a spanner icon +# near the name of nzb-file. +# +# o The script supports the feature called "delayed par-check". +# That means it can try to unpack downloaded files without par-checking +# them fisrt. Only if unpack fails, the script schedules par-check, +# then unpacks again. +# To use delayed par-check set following options in nzbget configuration file: +# ParCheck=no +# ParRepair=yes +# LoadPars=one (or) LoadPars=all +# +# o If you want to par-check/repair all files before trying to unpack them, +# set option "ParCheck=yes". +# +####################### End of Usage instructions ####################### + + + +# NZBGet passes following arguments to postprocess-programm as environment +# variables: +# NZBPP_DIRECTORY - path to destination dir for downloaded files; +# NZBPP_NZBFILENAME - name of processed nzb-file; +# NZBPP_PARFILENAME - name of par-file or empty string (if no collections were +# found); +# NZBPP_PARSTATUS - result of par-check: +# 0 = not checked: par-check disabled or nzb-file does +# not contain any par-files; +# 1 = checked and failed to repair; +# 2 = checked and successfully repaired; +# 3 = checked and can be repaired but repair is disabled; +# NZBPP_NZBCOMPLETED - state of nzb-job: +# 0 = there are more collections in this nzb-file queued; +# 1 = this was the last collection in nzb-file; +# NZBPP_PARFAILED - indication of failed par-jobs for current nzb-file: +# 0 = no failed par-jobs; +# 1 = current par-job or any of the previous par-jobs for +# the same nzb-files failed; +# NZBPP_CATEGORY - category assigned to nzb-file (can be empty string). + +# Toggle detailed output (0/1) +DEBUG=1 + +# Name of script's configuration file +SCRIPT_CONFIG_FILE="postprocess.conf" + +# Exit codes +POSTPROCESS_PARCHECK_CURRENT=91 +POSTPROCESS_PARCHECK_ALL=92 +POSTPROCESS_SUCCESS=93 +POSTPROCESS_ERROR=94 +POSTPROCESS_NONE=95 + +# Postprocessing function for nzbToCouchPotato for handling failed downloads +nzbToCouchPotato() { + if [ "$DEBUG" ]; then echo "[DETAIL] Post-Process: Executing function 'nzbToCouchPotato' with argument $1" ; fi + PostProcessStatus=0 + if [ -n "$1" ]; then PostProcessStatus=$1 ; fi + if [ "$CouchPotato" = "yes" -a "$NZBPP_CATEGORY" = "$CouchPotatoCategory" -a -e "$NzbToCouchPotato" ]; then + # Call Couchpotato's postprocessing script + echo "[INFO] Post-Process: Running CouchPotato's postprocessing script" + if [ "$DEBUG" ]; then + echo "[DETAIL] Post-Process: CouchPotato-Script-Path=$NzbToCouchPotato" + echo "[DETAIL] Post-Process: CouchPotato-Script-ARGV1=$NZBPP_DIRECTORY" + echo "[DETAIL] Post-Process: CouchPotato-Script-ARGV2=$NZBPP_NZBFILENAME" + echo "[DETAIL] Post-Process: CouchPotato-Script-ARGV3=$PostProcessStatus" + fi + #$PythonCmd $NzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" >/dev/null 2>&1 + $PythonCmd $NzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" + else + if [ "$CouchPotato" != "yes" ]; then echo "[DETAIL] Post-Process: Ignored to run CouchPotato's postprocessing script as it is disabled by user ('$CouchPotato')"; fi + if [ "$NZBPP_CATEGORY" != "CouchPotatoCategory" ]; then echo "[DETAIL] Post-Process: Ignored to run CouchPotato's postprocessing script as category does not match ('$NZBPP_CATEGORY')"; fi + fi +} + +# Pass on postprocess exit codes to external scripts for handling failed downloads +do_exit() { + if [ "$DEBUG" ]; then echo "[DETAIL] Post-Process: Executing function 'do_exit' with argument $1" ; fi + nzbStatus=0 + if [ "$1" -ne "$POSTPROCESS_SUCCESS" ]; then nzbStatus=1 ; fi + nzbToCouchPotato $nzbStatus + exit $1 +} + +# Check if the script is called from nzbget +if [ "$NZBPP_DIRECTORY" = "" -o "$NZBOP_CONFIGFILE" = "" ]; then + echo "*** NZBGet post-process script ***" + echo "This script is supposed to be called from nzbget (0.7.0 or later)." + exit $POSTPROCESS_ERROR +fi + +# Check if postprocessing was disabled in postprocessing parameters +# (for current nzb-file) via web-interface or via command line with +# "nzbget -E G O PostProcess=no " +if [ "$NZBPR_PostProcess" = "no" ]; then + echo "[WARNING] Post-Process: Postprocessing disabled for this nzb-file, exiting" + exit $POSTPROCESS_NONE +fi + +echo "[INFO] Post-Process: Post-process script successfully started" + +# Determine the location of configuration file (it must be stored in +# the directory with nzbget.conf or in this script's directory). +ConfigDir="${NZBOP_CONFIGFILE%/*}" +ScriptConfigFile="$ConfigDir/$SCRIPT_CONFIG_FILE" +if [ ! -f "$ScriptConfigFile" ]; then + ConfigDir="${0%/*}" + ScriptConfigFile="$ConfigDir/$SCRIPT_CONFIG_FILE" +fi +if [ ! -f "$ScriptConfigFile" ]; then + echo "[ERROR] Post-Process: Configuration file $ScriptConfigFile not found, exiting" + do_exit $POSTPROCESS_ERROR +fi + +# Readg configuration file +while read line; do eval "$line"; done < $ScriptConfigFile + +# Check nzbget.conf options +BadConfig=0 + +if [ "$NZBOP_ALLOWREPROCESS" = "yes" ]; then + echo "[ERROR] Post-Process: Please disable option \"AllowReProcess\" in nzbget configuration file" + BadConfig=1 +fi + +if [ "$NZBOP_LOADPARS" = "none" ]; then + echo "[ERROR] Post-Process: Please set option \"LoadPars\" to \"One\" or \"All\" in nzbget configuration file" + BadConfig=1 +fi + +if [ "$NZBOP_PARREPAIR" = "no" ]; then + echo "[ERROR] Post-Process: Please set option \"ParRepair\" to \"Yes\" in nzbget configuration file" + BadConfig=1 +fi + +if [ "$BadConfig" -eq 1 ]; then + echo "[ERROR] Post-Process: Existing because of not compatible nzbget configuration" + do_exit $POSTPROCESS_ERROR +fi + +# Check if all collections in nzb-file were downloaded +if [ ! "$NZBPP_NZBCOMPLETED" -eq 1 ]; then + echo "[INFO] Post-Process: Not the last collection in nzb-file, exiting" + do_exit $POSTPROCESS_SUCCESS +fi + +# Check par status +if [ "$NZBPP_PARSTATUS" -eq 1 -o "$NZBPP_PARSTATUS" -eq 3 -o "$NZBPP_PARFAILED" -eq 1 ]; then + if [ "$NZBPP_PARSTATUS" -eq 3 ]; then + echo "[WARNING] Post-Process: Par-check successful, but Par-repair disabled, exiting" + else + echo "[WARNING] Post-Process: Par-check failed, exiting" + fi + #nzbToCouchPotato + do_exit $POSTPROCESS_ERROR +fi + +# Check if destination directory exists (important for reprocessing of history items) +if [ ! -d "$NZBPP_DIRECTORY" ]; then + echo "[ERROR] Post-Process: Nothing to post-process: destination directory $NZBPP_DIRECTORY doesn't exist" + do_exit $POSTPROCESS_ERROR +fi + +cd "$NZBPP_DIRECTORY" + +# If not just repaired and file "_brokenlog.txt" exists, the collection is damaged +# exiting with returning code $POSTPROCESS_PARCHECK_ALL to request par-repair +if [ ! "$NZBPP_PARSTATUS" -eq 2 ]; then + if [ -f "_brokenlog.txt" ]; then + if (ls *.[pP][aA][rR]2 >/dev/null 2>&1); then + echo "[INFO] Post-Process: Brokenlog found, requesting par-repair" + do_exit $POSTPROCESS_PARCHECK_ALL + fi + fi +fi + +# All checks done, now processing the files + +# Flag indicates that something was unrared +Unrared=0 + +# Unrar the files (if any) to the temporary directory, if there are no rar files this will do nothing +if (ls *.rar >/dev/null 2>&1); then + + # Check if unrar exists + $UnrarCmd >/dev/null 2>&1 + if [ "$?" -eq 127 ]; then + echo "[ERROR] Post-Process: Unrar not found. Set the path to unrar in script's configuration" + do_exit $POSTPROCESS_ERROR + fi + + # Make a temporary directory to store the unrarred files + ExtractedDirExists=0 + if [ -d $ExtractedDir ]; then + ExtractedDirExists=1 + else + mkdir $ExtractedDir + fi + + echo "[INFO] Post-Process: Unraring" + rarpasswordparam="" + if [ "$NZBPR_Password" != "" ]; then + rarpasswordparam="-p$NZBPR_Password" + fi + + $UnrarCmd x -y -p- "$rarpasswordparam" -o+ "*.rar" ./$ExtractedDir/ + if [ "$?" -eq 3 ]; then + echo "[ERROR] Post-Process: Unrar failed" + if [ "$ExtractedDirExists" -eq 0 ]; then + rm -R $ExtractedDir + fi + # for delayed par-check/-repair at least one par-file must be already downloaded + if (ls *.[pP][aA][rR]2 >/dev/null 2>&1); then + echo "[INFO] Post-Process: Requesting par-repair" + do_exit $POSTPROCESS_PARCHECK_ALL + fi + do_exit $POSTPROCESS_ERROR + fi + Unrared=1 + + # Remove the rar files + if [ "$DeleteRarFiles" = "yes" ]; then + echo "[INFO] Post-Process: Deleting rar-files" + rm *.r[0-9][0-9] >/dev/null 2>&1 + rm *.rar >/dev/null 2>&1 + rm *.s[0-9][0-9] >/dev/null 2>&1 + fi + + # Go to the temp directory and try to unrar again. + # If there are any rars inside the extracted rars then these will no also be unrarred + cd $ExtractedDir + if (ls *.rar >/dev/null 2>&1); then + echo "[INFO] Post-Process: Unraring (second pass)" + $UnrarCmd x -y -p- -o+ "*.rar" + + if [ "$?" -eq 3 ]; then + echo "[INFO] Post-Process: Unrar (second pass) failed" + do_exit $POSTPROCESS_ERROR + fi + + # Delete the Rar files + if [ "$DeleteRarFiles" = "yes" ]; then + echo "[INFO] Post-Process: Deleting rar-files (second pass)" + rm *.r[0-9][0-9] >/dev/null 2>&1 + rm *.rar >/dev/null 2>&1 + rm *.s[0-9][0-9] >/dev/null 2>&1 + fi + fi + + # Move everything back to the Download folder + mv * .. + cd .. + rmdir $ExtractedDir +fi + +# If download contains only nzb-files move them into nzb-directory +# for further download +# Check if command "wc" exists +wc -l . >/dev/null 2>&1 +if [ "$?" -ne 127 ]; then + AllFilesCount=`ls -1 2>/dev/null | wc -l` + NZBFilesCount=`ls -1 *.nzb 2>/dev/null | wc -l` + if [ "$AllFilesCount" -eq "$NZBFilesCount" ]; then + echo "[INFO] Moving downloaded nzb-files into incoming nzb-directory for further download" + mv *.nzb $NZBOP_NZBDIR + fi +fi + +# Clean up +echo "[INFO] Post-Process: Cleaning up" +chmod -R a+rw . +rm *.nzb >/dev/null 2>&1 +rm *.sfv >/dev/null 2>&1 +rm *.1 >/dev/null 2>&1 +rm _brokenlog.txt >/dev/null 2>&1 +if [ "$Unrared" -eq 1 ]; then + # Delete par2-file only if there were files for unpacking. + rm *.[pP][aA][rR]2 >/dev/null 2>&1 +fi + +if [ "$JoinTS" = "yes" ]; then + # Join any split .ts files if they are named xxxx.0000.ts xxxx.0001.ts + # They will be joined together to a file called xxxx.0001.ts + if (ls *.ts >/dev/null 2>&1); then + echo "[INFO] Post-Process: Joining ts-files" + tsname=`find . -name "*0001.ts" |awk -F/ '{print $NF}'` + cat *0???.ts > ./$tsname + fi + + # Remove all the split .ts files + echo "[INFO] Post-Process: Deleting source ts-files" + rm *0???.ts >/dev/null 2>&1 +fi + +if [ "$RenameIMG" = "yes" ]; then + # Rename img file to iso + # It will be renamed to .img.iso so you can see that it has been renamed + if (ls *.img >/dev/null 2>&1); then + echo "[INFO] Post-Process: Renaming img-files to iso" + imgname=`find . -name "*.img" |awk -F/ '{print $NF}'` + mv $imgname $imgname.iso + fi +fi + +if [ "$SickBeard" = "yes" -a "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -e "$SabToSickBeard" ]; then + # Call SickBeard's postprocessing script + echo "[INFO] Post-Process: Running SickBeard's postprocessing script" + #$PythonCmd $SabToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" >/dev/null 2>&1 + $PythonCmd $SabToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" +fi + + + +# Check if destination directory was set in postprocessing parameters +# (for current nzb-file) via web-interface or via command line with +# "nzbget -E G O DestDir=/new/path " +if [ "$NZBPR_DestDir" != "" ]; then + mkdir $NZBPR_DestDir + mv * $NZBPR_DestDir >/dev/null 2>&1 + cd .. + rmdir $NZBPP_DIRECTORY +fi + +# All OK, requesting cleaning up of download queue +do_exit $POSTPROCESS_SUCCESS diff --git a/nzbget-postprocessing-files/0.8.0/postprocess.sh b/nzbget-postprocessing-files/0.8.0/postprocess.sh index 845863d4..f76a9ac5 100644 --- a/nzbget-postprocessing-files/0.8.0/postprocess.sh +++ b/nzbget-postprocessing-files/0.8.0/postprocess.sh @@ -357,7 +357,7 @@ if [ "$NZBPP_CATEGORY" = "$SickBeardCategory" -a -d "$TvDownloadDir" ]; then fi fi # Test for category and ensure the passed directory exists as a directory. -if [ "$NZBPP_CATEGORY" = "$CouchPotatoCategory" -a -d "$MoviesDownloadDir' ]; then +if [ "$NZBPP_CATEGORY" = "$CouchPotatoCategory" -a -d "$MoviesDownloadDir" ]; then echo "[INFO] Post-Process: Moving Movies to $MoviesDownloadDir" cp -R "$NZBPP_DIRECTORY" "$MoviesDownloadDir" >/dev/null 2>&1 if [ "$?" -ne 0 ]; then