From 52eed2ba6861438e535da542ec3b927fe88ef6ba Mon Sep 17 00:00:00 2001 From: Clinton Hall Date: Fri, 22 Mar 2013 19:42:28 -0700 Subject: [PATCH] fix append log --- .../current-stable/nzbget-postprocess.sh | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/nzbget-postprocessing-files/current-stable/nzbget-postprocess.sh b/nzbget-postprocessing-files/current-stable/nzbget-postprocess.sh index a274fec7..b4cf5355 100644 --- a/nzbget-postprocessing-files/current-stable/nzbget-postprocess.sh +++ b/nzbget-postprocessing-files/current-stable/nzbget-postprocess.sh @@ -114,7 +114,7 @@ nzbToMedia() { echo "[DETAIL] Post-Process: CouchPotato-Script-ARGV2=$NZBPP_NZBFILENAME" | tee -a $tmplog echo "[DETAIL] Post-Process: CouchPotato-Script-ARGV3=$PostProcessStatus" | tee -a $tmplog fi - $PythonCmd $NzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" | while read line ; do if [ "$line" != "" ] ; then echo "[INFO] Post-Process: $line" ; fi ; done + $PythonCmd $NzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" | while read line ; do if [ "$line" != "" ] ; then replaceLogLine "${line}" ; fi ; done else if [ "$CouchPotato" != "yes" ]; then echo "[DETAIL] Post-Process: Ignored to run CouchPotato's postprocessing script as it is disabled by user ('$CouchPotato')" | tee -a $tmplog; fi if [ ! -e "$NzbToCouchPotato" ]; then echo "[DETAIL] Post-Process: Ignored to run CouchPotato's postprocessing script as the specified script ('$NzbToCouchPotato') does not exist" | tee -a $tmplog; fi @@ -131,7 +131,7 @@ nzbToMedia() { echo "[DETAIL] Post-Process: SickBeard-Script-ARGV2=$NZBPP_NZBFILENAME" | tee -a $tmplog echo "[DETAIL] Post-Process: SickBeard-Script-ARGV3=$PostProcessStatus" | tee -a $tmplog fi - $PythonCmd $NzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" | while read line ; do if [ "$line" != "" ] ; then echo "[INFO] Post-Process: $line" ; fi ; done + $PythonCmd $NzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" | while read line ; do if [ "$line" != "" ] ; then replaceLogLine "${line}" ; fi ; done else if [ "$SickBeard" != "yes" ]; then echo "[DETAIL] Post-Process: Ignored to run SickBeard's postprocessing script as it is disabled by user ('$SickBeard')" | tee -a $tmplog; fi if [ ! -e "$NzbToSickBeard" ]; then echo "[DETAIL] Post-Process: Ignored to run SickBeard's postprocessing script as the specified script ('$NzbToSickBeard') does not exist" | tee -a $tmplog; fi @@ -148,7 +148,7 @@ nzbToMedia() { echo "[DETAIL] Post-Process: Custom-Script-ARGV2=$NZBPP_NZBFILENAME" | tee -a $tmplog echo "[DETAIL] Post-Process: Custom-Script-ARGV3=$PostProcessStatus" | tee -a $tmplog fi - $CustomCmd $CustomScript "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" | while read line ; do if [ "$line" != "" ] ; then echo "[INFO] Post-Process: $line" ; fi ; done + $CustomCmd $CustomScript "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" | while read line ; do if [ "$line" != "" ] ; then replaceLogLine "${line}" ; fi ; done else if [ "$Custom" != "yes" ]; then echo "[DETAIL] Post-Process: Ignored to run the Custom postprocessing script as it is disabled by user ('$Custom')" | tee -a $tmplog; fi if [ ! -e "$CustomScript" ]; then echo "[DETAIL] Post-Process: Ignored to run the Custom postprocessing script as the specified script ('$CustomScript') does not exist" | tee -a $tmplog; fi @@ -169,6 +169,23 @@ replaceVarBy() { if [ "$Debug" = "yes" ]; then echo "[DETAIL] Post-Process: replace result: ${REPLACEDRESULT}" | tee -a $tmplog; fi } +replaceLogLine() { + # This converts the output logigng from nzbTo* script to a compatible format with NZBGet + # If we're not using Bash use sed, as we need to support as much as systems possible, also those running sh/dash etc + if [ -n "${BASH_VERSION}" ]; then + newline="${1/*DEBUG/[DETAIL]}" + newline="${newline/*INFO/[INFO]}" + newline="${newline/*WARNING/[WARNING]}" + newline="${newline/*ERROR/[ERROR]}" + else + newline=$(echo "${1}" | sed "s^.*DEBUG^[DETAIL]^") + newline=$(echo $newline | sed "s^.*INFO^[INFO]^") + newline=$(echo $newline | sed "s^.*WARNING^[WARNING]^") + newline=$(echo $newline | sed "s^.*ERROR^[ERROR]^") + fi + echo "$newline" | tee -a $tmplog +} + # Pass on postprocess exit codes to external scripts for handling failed downloads do_exit() { if [ "$Debug" = "yes" ]; then echo "[DETAIL] Post-Process: Executing function 'do_exit' with argument $1" | tee -a $tmplog; fi