diff --git a/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh b/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh index 0beebb18..df854d76 100644 --- a/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh +++ b/nzbget-postprocessing-files/9.0/bin/nzbget-postprocess.sh @@ -155,6 +155,19 @@ nzbToMedia() { fi } +replaceVarBy() { + if [ "$Debug" = "yes" ]; then echo "[DETAIL] Post-Process: Executing function 'replaceVarBy'. Going to replace '${2}' in '${1}' by '${3}'" ; fi + + # 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 + REPLACEDRESULT="${1/${2}/${3}}" + else + REPLACEDRESULT=$(echo "${1}" | sed "s/${2}/${3}/") + fi + + if [ "$Debug" = "yes" ]; then echo "[DETAIL] Post-Process: replace result: ${REPLACEDRESULT}" ; fi +} + # 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" ; fi @@ -162,24 +175,31 @@ do_exit() { if [ "$1" -ne "$POSTPROCESS_SUCCESS" ]; then nzbStatus=1 ; fi script=none nzbToMedia $nzbStatus - Email_Subject="${Email_Subject//$NZBPP_NZBFILENAME}" - Email_Subject="${Email_Subject//$NZBPP_CATEGORY}" - Email_Subject="${Email_Subject/