mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-22 06:13:19 -07:00
Merge 10a7431cb7
into 9052bf6468
This commit is contained in:
commit
83f2c29456
1 changed files with 30 additions and 10 deletions
|
@ -155,6 +155,19 @@ nzbToMedia() {
|
||||||
fi
|
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
|
# Pass on postprocess exit codes to external scripts for handling failed downloads
|
||||||
do_exit() {
|
do_exit() {
|
||||||
if [ "$Debug" = "yes" ]; then echo "[DETAIL] Post-Process: Executing function 'do_exit' with argument $1" ; fi
|
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
|
if [ "$1" -ne "$POSTPROCESS_SUCCESS" ]; then nzbStatus=1 ; fi
|
||||||
script=none
|
script=none
|
||||||
nzbToMedia $nzbStatus
|
nzbToMedia $nzbStatus
|
||||||
Email_Subject="${Email_Subject/<name>/$NZBPP_NZBFILENAME}"
|
echo "[DETAIL] after calling nzbToMedia"
|
||||||
Email_Subject="${Email_Subject/<cat>/$NZBPP_CATEGORY}"
|
replaceVarBy "${Email_Subject}" "<name>" "${NZBPP_NZBFILENAME}"
|
||||||
Email_Subject="${Email_Subject/<script>/$script}"
|
replaceVarBy "${REPLACEDRESULT}" "<cat>" "${NZBPP_CATEGORY}"
|
||||||
Email_Message="${Email_Message/<name>/$NZBPP_NZBFILENAME}"
|
replaceVarBy "${REPLACEDRESULT}" "<script>" "${script}"
|
||||||
Email_Message="${Email_Message/<cat>/$NZBPP_CATEGORY}"
|
Email_Subject="${REPLACEDRESULT}"
|
||||||
Email_Message="${Email_Message/<script>/$script}"
|
replaceVarBy "${Email_Message}" "<name>" "${NZBPP_NZBFILENAME}"
|
||||||
|
replaceVarBy "${REPLACEDRESULT}" "<cat>" "${NZBPP_CATEGORY}"
|
||||||
|
replaceVarBy "${REPLACEDRESULT}" "<script>" "${script}"
|
||||||
|
Email_Message="${REPLACEDRESULT}"
|
||||||
if [ "$Email_successful" = "yes" -a "$nzbStatus" = 0 ]; then
|
if [ "$Email_successful" = "yes" -a "$nzbStatus" = 0 ]; then
|
||||||
User=""
|
User=""
|
||||||
if [ -n "$Email_User" -a -n "$Email_Pass" ]; then User="-xu $Email_User -xp $Email_Pass" ; fi
|
if [ -n "$Email_User" -a -n "$Email_Pass" ]; then User="-xu $Email_User -xp $Email_Pass" ; fi
|
||||||
Email_Subject="${Email_Subject/<status>/completed}"
|
replaceVarBy "${Email_Subject}" "<status>" "completed"
|
||||||
Email_Message="${Email_Message/<status>/completed}"
|
Email_Subject="${REPLACEDRESULT}"
|
||||||
|
replaceVarBy "${Email_Message}" "<status>" "completed"
|
||||||
|
Email_Message="${REPLACEDRESULT}"
|
||||||
$sendEmail -f "$Email_From" -t "$Email_To" -s "$Email_Server" $User -u "$Email_Subject" -m "$Email_Message"
|
$sendEmail -f "$Email_From" -t "$Email_To" -s "$Email_Server" $User -u "$Email_Subject" -m "$Email_Message"
|
||||||
fi
|
fi
|
||||||
if [ "$Email_failed" = "yes" -a "$nzbStatus" != 0 ]; then
|
if [ "$Email_failed" = "yes" -a "$nzbStatus" != 0 ]; then
|
||||||
User=""
|
User=""
|
||||||
if [ -n "$Email_User" -a -n "$Email_Pass" ]; then User="-xu $Email_User -xp $Email_Pass" ; fi
|
if [ -n "$Email_User" -a -n "$Email_Pass" ]; then User="-xu $Email_User -xp $Email_Pass" ; fi
|
||||||
Email_Subject="${Email_Subject/<status>/failed}"
|
replaceVarBy "${Email_Subject}" "<status>" "failed"
|
||||||
Email_Message="${Email_Message/<status>/failed}"
|
Email_Subject="${REPLACEDRESULT}"
|
||||||
|
replaceVarBy "${Email_Message}" "<status>" "failed"
|
||||||
|
Email_Message="${REPLACEDRESULT}"
|
||||||
$sendEmail -f "$Email_From" -t "$Email_To" -s "$Email_Server" $User -u "$Email_Subject" -m "$Email_Message"
|
$sendEmail -f "$Email_From" -t "$Email_To" -s "$Email_Server" $User -u "$Email_Subject" -m "$Email_Message"
|
||||||
fi
|
fi
|
||||||
exit $1
|
exit $1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue