mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 12:59:36 -07:00
Merge remote-tracking branch 'origin/dev'
This commit is contained in:
commit
32a7bef582
4 changed files with 104 additions and 278 deletions
10
README.md
10
README.md
|
@ -237,8 +237,9 @@ If you are using NZBGet perform the following steps to configure postprocessing
|
||||||
|
|
||||||
2. In NZBGet go to "POSTPROCESSING SCRIPT" -> "PATHS" and change as needed:
|
2. In NZBGet go to "POSTPROCESSING SCRIPT" -> "PATHS" and change as needed:
|
||||||
|
|
||||||
i. Set the full path to python if it is not in your PATH.
|
i. Set the full path to python if it is not in your PATH. (option is required)
|
||||||
|
These scripts now have -x permissions and should be as such on your system. Python needs to be in your system path.
|
||||||
|
|
||||||
PythonCmd=/usr/local/python/bin/python
|
PythonCmd=/usr/local/python/bin/python
|
||||||
|
|
||||||
ii. Set the full path to sabToSickBeard.py for SickBeard's postprocessing.
|
ii. Set the full path to sabToSickBeard.py for SickBeard's postprocessing.
|
||||||
|
@ -246,6 +247,7 @@ If you are using NZBGet perform the following steps to configure postprocessing
|
||||||
NzbToSickBeard=/usr/local/nzbget/var/nzbToSickBeard.py
|
NzbToSickBeard=/usr/local/nzbget/var/nzbToSickBeard.py
|
||||||
|
|
||||||
iii. Set the full path where completed movies should be placed before SickBeard's Renamer is called (option)
|
iii. Set the full path where completed movies should be placed before SickBeard's Renamer is called (option)
|
||||||
|
(v 9.0 only). For n 10.0 set this in the appropriate category settings in the Categories Section.
|
||||||
|
|
||||||
TvDownloadDir=
|
TvDownloadDir=
|
||||||
|
|
||||||
|
@ -254,10 +256,11 @@ If you are using NZBGet perform the following steps to configure postprocessing
|
||||||
NzbToCouchPotato=/usr/local/nzbget/var/nzbToCouchPotato.py
|
NzbToCouchPotato=/usr/local/nzbget/var/nzbToCouchPotato.py
|
||||||
|
|
||||||
v. Set the full path where completed movies should be placed before CouchPotato's Renamer is called (option)
|
v. Set the full path where completed movies should be placed before CouchPotato's Renamer is called (option)
|
||||||
|
(v 9.0 only). For n 10.0 set this in the appropriate category settings in the Categories Section.
|
||||||
|
|
||||||
MoviesDownloadDir=
|
MoviesDownloadDir=
|
||||||
|
|
||||||
vi. Set the full path to any dependency required for your Custom Postprocess script if it is not in your PATH.
|
vi. Set the full path to any dependency required for your Custom Postprocess script if it is not in your PATH.(option is required)
|
||||||
|
|
||||||
CustomCmd=/usr/local/python/bin/python
|
CustomCmd=/usr/local/python/bin/python
|
||||||
|
|
||||||
|
@ -266,6 +269,7 @@ If you are using NZBGet perform the following steps to configure postprocessing
|
||||||
CustomScript=
|
CustomScript=
|
||||||
|
|
||||||
viii.Set the full path where completed downloads should be placed before the Custom postprocess is called (option)
|
viii.Set the full path where completed downloads should be placed before the Custom postprocess is called (option)
|
||||||
|
(v 9.0 only). For n 10.0 set this in the appropriate category settings in the Categories Section.
|
||||||
|
|
||||||
CustomDownloadDir=
|
CustomDownloadDir=
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
#
|
#
|
||||||
# This file if part of nzbget
|
# This file if part of nzbget
|
||||||
#
|
#
|
||||||
# Template configuration file for postprocessing script "nzbget-postprocess.sh".
|
# Template configuration file for post-processing script "nzbget-postprocess.sh".
|
||||||
# Please refer to "nzbget-postprocess.sh" for usage instructions.
|
# Please refer to "nzbget-postprocess.sh" for usage instructions.
|
||||||
#
|
#
|
||||||
# Copyright (C) 2008-2012 Andrey Prygunkov <hugbug@users.sourceforge.net>
|
# Copyright (C) 2008-2013 Andrey Prygunkov <hugbug@users.sourceforge.net>
|
||||||
# Copyright (C) 2012 J<>rgen Seif <thor78@gmx.at>
|
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -26,26 +25,15 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
### PATHS ###
|
### PATHS ###
|
||||||
|
|
||||||
# Set the full path to unrar if it is not in your PATH.
|
|
||||||
UnrarCmd=unrar
|
|
||||||
|
|
||||||
# Set the full path to python if it is not in your PATH.
|
# Set the full path to python if it is not in your PATH.
|
||||||
PythonCmd=/usr/local/python/bin/python
|
PythonCmd=/usr/local/python/bin/python
|
||||||
|
|
||||||
# Set the full path to sabToSickBeard.py for SickBeard's postprocessing.
|
# Set the full path to sabToSickBeard.py for SickBeard's postprocessing.
|
||||||
NzbToSickBeard=/usr/local/nzbget/var/nzbToSickBeard.py
|
NzbToSickBeard=/usr/local/nzbget/var/nzbToSickBeard.py
|
||||||
|
|
||||||
# Set the full path where completed movies should be placed
|
|
||||||
# before SickBeard's Renamer is called
|
|
||||||
TvDownloadDir=
|
|
||||||
|
|
||||||
# Set the full path to nzbToCouchpotato.py for Couchpotato's postprocessing
|
# Set the full path to nzbToCouchpotato.py for Couchpotato's postprocessing
|
||||||
NzbToCouchPotato=/usr/local/nzbget/var/nzbToCouchPotato.py
|
NzbToCouchPotato=/usr/local/nzbget/var/nzbToCouchPotato.py
|
||||||
|
|
||||||
# Set the full path where completed movies should be placed
|
|
||||||
# before CouchPotato's Renamer is called
|
|
||||||
MoviesDownloadDir=
|
|
||||||
|
|
||||||
# Set the full path to any dependency required for your Custom
|
# Set the full path to any dependency required for your Custom
|
||||||
# Postprocess script if it is not in your PATH.
|
# Postprocess script if it is not in your PATH.
|
||||||
CustomCmd=/usr/local/python/bin/python
|
CustomCmd=/usr/local/python/bin/python
|
||||||
|
@ -53,24 +41,14 @@ CustomCmd=/usr/local/python/bin/python
|
||||||
# Set the full path to the Custom Postprocess script.
|
# Set the full path to the Custom Postprocess script.
|
||||||
CustomScript=
|
CustomScript=
|
||||||
|
|
||||||
# Set the full path where completed downloads should be placed
|
|
||||||
# before the Custom postprocess is called
|
|
||||||
CustomDownloadDir=
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
### OPTIONS ###
|
### OPTIONS ###
|
||||||
|
|
||||||
# Delete rar-files after unpacking (yes, no).
|
|
||||||
DeleteRarFiles=yes
|
|
||||||
|
|
||||||
# Temporary directory for unpacking.
|
|
||||||
ExtractedDir=extracted
|
|
||||||
|
|
||||||
# Rename img-files to iso (yes, no).
|
# Rename img-files to iso (yes, no).
|
||||||
RenameIMG=yes
|
RenameIMG=yes
|
||||||
|
|
||||||
# Joint TS-files (yes, no).
|
# Joint TS-files (yes, no).
|
||||||
JoinTS=no
|
JoinTS=yes
|
||||||
|
|
||||||
# Perform SickBeard's postprocessing (yes, no).
|
# Perform SickBeard's postprocessing (yes, no).
|
||||||
SickBeard=yes
|
SickBeard=yes
|
||||||
|
@ -80,17 +58,17 @@ SickBeardCategory=tv
|
||||||
|
|
||||||
# Perform Couchpotato's postprocessing (yes, no).
|
# Perform Couchpotato's postprocessing (yes, no).
|
||||||
CouchPotato=yes
|
CouchPotato=yes
|
||||||
|
|
||||||
# Category for Couchpotato's postprocessing (eg. movies)
|
# Category for Couchpotato's postprocessing.
|
||||||
CouchPotatoCategory=movies
|
CouchPotatoCategory=movies
|
||||||
|
|
||||||
# Perform Custom postprocessing (yes, no).
|
# Perform Custom postprocessing (yes, no).
|
||||||
Custom=yes
|
Custom=yes
|
||||||
|
|
||||||
# Category for Custom postprocessing (eg. movies)
|
# Category for Custom postprocessing (eg. movies)
|
||||||
CustomCategory=music
|
CustomCategory=music
|
||||||
|
|
||||||
# Clean up list. space seperated, in single quote, default '*.nzb *.sfv *.1'
|
# Clean up list. space seperated, in single quotes, default '*.nzb *.sfv *.1'
|
||||||
FileCleanUp='*.nzb *.sfv *.1'
|
FileCleanUp='*.nzb *.sfv *.1'
|
||||||
|
|
||||||
# Toggle detailed output (yes, no).
|
# Toggle detailed output (yes, no).
|
||||||
|
@ -101,23 +79,16 @@ Debug=no
|
||||||
|
|
||||||
# This section defines parameters, which can be set for each nzb-file
|
# This section defines parameters, which can be set for each nzb-file
|
||||||
# individually using either web-interface or command line.
|
# individually using either web-interface or command line.
|
||||||
# Example command line for setting parameter "password" to value "123" for
|
# Example command line for setting parameter "PostProcess" to value "no" for
|
||||||
# nzb-file with id=2:
|
# nzb-file with id=2:
|
||||||
# nzbget -E G O Password=123 2
|
# nzbget -E G O PostProcess=no 2
|
||||||
|
|
||||||
# Perform postprocessing (yes, no).
|
# Perform postprocessing (yes, no).
|
||||||
#
|
#
|
||||||
# Set to "no" to skip postprocessing for this nzb-file.
|
# Set to "no" to skip postprocessing for this nzb-file.
|
||||||
PostProcess=yes
|
PostProcess=yes
|
||||||
|
|
||||||
# Password for encrypted posts.
|
|
||||||
#
|
|
||||||
# If the post requires a password for unpacking.
|
|
||||||
Password=
|
|
||||||
|
|
||||||
# Destination directory.
|
# Destination directory.
|
||||||
#
|
|
||||||
# NOTE: NZBGet must have write-access-rights for that directory.
|
|
||||||
DestDir=
|
DestDir=
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
@ -127,11 +98,11 @@ DestDir=
|
||||||
# be sent via email.
|
# be sent via email.
|
||||||
# This uses sendEmail as authored by Brandon Zehm <caspian@dotconf.net>
|
# This uses sendEmail as authored by Brandon Zehm <caspian@dotconf.net>
|
||||||
|
|
||||||
# Specify if you want emails to be sent for successful downloads (yes, no).
|
# List Categories for successful download email, default 'tv movies'
|
||||||
Email_successful=yes
|
Email_successful='tv movies'
|
||||||
|
|
||||||
# Specify if you want emails to be sent for failed downloads (yes, no).
|
# List Categories for failed download email, default 'tv movies'
|
||||||
Email_failed=yes
|
Email_failed='tv movies'
|
||||||
|
|
||||||
# Set the full path and file name for sendEmail application.
|
# Set the full path and file name for sendEmail application.
|
||||||
sendEmail=/usr/local/nzbget/var/sendEmail/sendEmail
|
sendEmail=/usr/local/nzbget/var/sendEmail/sendEmail
|
314
nzbget-postprocessing-files/0.8.0/postprocess.sh → nzbget-postprocessing-files/10.0/nzbget-postprocess.sh
Normal file → Executable file
314
nzbget-postprocessing-files/0.8.0/postprocess.sh → nzbget-postprocessing-files/10.0/nzbget-postprocess.sh
Normal file → Executable file
|
@ -1,13 +1,12 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# -*- coding: cp1252 -*-
|
#
|
||||||
|
# This file if part of nzbget
|
||||||
#
|
#
|
||||||
# Example postprocessing script for NZBGet
|
# Example postprocessing script for NZBGet
|
||||||
#
|
#
|
||||||
# Copyright (C) 2008 Peter Roubos <peterroubos@hotmail.com>
|
# Copyright (C) 2008 Peter Roubos <peterroubos@hotmail.com>
|
||||||
# Copyright (C) 2008 Otmar Werner
|
# Copyright (C) 2008 Otmar Werner
|
||||||
# Copyright (C) 2008-2012 Andrei Prygunkov <hugbug@users.sourceforge.net>
|
# Copyright (C) 2008-2013 Andrey Prygunkov <hugbug@users.sourceforge.net>
|
||||||
# Copyright (C) 2012 Antoine Bertin <diaoulael@gmail.com>
|
|
||||||
# Copyright (C) 2012 J<>rgen Seif <thor78@gmx.at>
|
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -21,45 +20,25 @@
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
####################### Usage instructions #######################
|
####################### Usage instructions #######################
|
||||||
# o Script will unrar downloaded rar files, join ts-files and rename img-files
|
# o Script will cleanup, join ts-files and rename img-files to iso.
|
||||||
# to iso.
|
|
||||||
#
|
#
|
||||||
# o To use this script with nzbget set the option "PostProcess" in
|
# o To use this script with nzbget set the option "PostProcess" in
|
||||||
# nzbget configuration file to point to this script file. E.g.:
|
# nzbget configuration file to point to this script file. E.g.:
|
||||||
# PostProcess=/home/user/nzbget/nzbget-postprocess.sh
|
# PostProcess=/home/user/nzbget/nzbget-postprocess.sh
|
||||||
#
|
#
|
||||||
# o The script needs a configuration file. An example configuration file
|
# o The script needs a configuration file. An example configuration file
|
||||||
# is provided in file "postprocess-example.conf". Put the configuration file
|
# is provided in file "nzbget-postprocess.conf". Put the configuration file
|
||||||
# into the directory where nzbget's configuration file (nzbget.conf) or where
|
# into the directory where nzbget's configuration file (nzbget.conf) is located.
|
||||||
# this script itself is located. Then edit the configuration file in any
|
# Then edit the configuration file in any text editor to adjust the settings.
|
||||||
# text editor to adjust the settings.
|
|
||||||
#
|
#
|
||||||
# o You can also edit the script's configuration via web-interface (requires
|
# o You can also edit the script's configuration via web-interface.
|
||||||
# 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
|
# o There are few options, which can be ajdusted for each nzb-file individually.
|
||||||
# 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 #######################
|
####################### End of Usage instructions #######################
|
||||||
|
|
||||||
|
@ -67,27 +46,27 @@
|
||||||
# NZBGet passes following arguments to postprocess-programm as environment
|
# NZBGet passes following arguments to postprocess-programm as environment
|
||||||
# variables:
|
# variables:
|
||||||
# NZBPP_DIRECTORY - path to destination dir for downloaded files;
|
# NZBPP_DIRECTORY - path to destination dir for downloaded files;
|
||||||
# NZBPP_NZBFILENAME - name of processed nzb-file;
|
# NZBPP_NZBNAME - user-friendly name of processed nzb-file as it is displayed
|
||||||
# NZBPP_PARFILENAME - name of par-file or empty string (if no collections were
|
# by the program. The file path and extension are removed.
|
||||||
# found);
|
# If download was renamed, this parameter reflects the new name;
|
||||||
|
# NZBPP_NZBFILENAME - name of processed nzb-file. It includes file extension and also
|
||||||
|
# may include full path;
|
||||||
|
# NZBPP_CATEGORY - category assigned to nzb-file (can be empty string);
|
||||||
# NZBPP_PARSTATUS - result of par-check:
|
# NZBPP_PARSTATUS - result of par-check:
|
||||||
# 0 = not checked: par-check disabled or nzb-file does
|
# 0 = not checked: par-check is disabled or nzb-file does
|
||||||
# not contain any par-files;
|
# not contain any par-files;
|
||||||
# 1 = checked and failed to repair;
|
# 1 = checked and failed to repair;
|
||||||
# 2 = checked and successfully repaired;
|
# 2 = checked and successfully repaired;
|
||||||
# 3 = checked and can be repaired but repair is disabled;
|
# 3 = checked and can be repaired but repair is disabled.
|
||||||
# NZBPP_NZBCOMPLETED - state of nzb-job:
|
# NZBPP_UNPACKSTATUS - result of unpack:
|
||||||
# 0 = there are more collections in this nzb-file queued;
|
# 0 = unpack is disabled or was skipped due to nzb-file
|
||||||
# 1 = this was the last collection in nzb-file;
|
# properties or due to errors during par-check;
|
||||||
# NZBPP_PARFAILED - indication of failed par-jobs for current nzb-file:
|
# 1 = unpack failed;
|
||||||
# 0 = no failed par-jobs;
|
# 2 = unpack successful.
|
||||||
# 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).
|
|
||||||
|
|
||||||
|
|
||||||
# Name of script's configuration file
|
# Name of script's configuration file
|
||||||
SCRIPT_CONFIG_FILE="postprocess.conf"
|
SCRIPT_CONFIG_FILE="nzbget-postprocess.conf"
|
||||||
|
|
||||||
# Exit codes
|
# Exit codes
|
||||||
POSTPROCESS_PARCHECK_CURRENT=91
|
POSTPROCESS_PARCHECK_CURRENT=91
|
||||||
|
@ -102,6 +81,7 @@ nzbToMedia() {
|
||||||
PostProcessStatus=0
|
PostProcessStatus=0
|
||||||
if [ -n "$1" ]; then PostProcessStatus=$1 ; fi
|
if [ -n "$1" ]; then PostProcessStatus=$1 ; fi
|
||||||
if [ "$Debug" = "yes" ]; then echo "[DETAIL] Post-Process: comparing '$NZBPP_CATEGORY' to '$CouchPotatoCategory' and '$SickBeardCategory'" ; fi
|
if [ "$Debug" = "yes" ]; then echo "[DETAIL] Post-Process: comparing '$NZBPP_CATEGORY' to '$CouchPotatoCategory' and '$SickBeardCategory'" ; fi
|
||||||
|
find "$NZBPP_DIRECTORY" -type f -size -200000k -iname \*sample\* -exec rm {} \; >/dev/null 2>&1
|
||||||
if [ "$NZBPP_CATEGORY" = "$CouchPotatoCategory" ]; then
|
if [ "$NZBPP_CATEGORY" = "$CouchPotatoCategory" ]; then
|
||||||
if [ "$CouchPotato" = "yes" -a -e "$NzbToCouchPotato" ]; then
|
if [ "$CouchPotato" = "yes" -a -e "$NzbToCouchPotato" ]; then
|
||||||
script=$NzbToCouchPotato
|
script=$NzbToCouchPotato
|
||||||
|
@ -155,6 +135,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}^g")
|
||||||
|
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,41 +155,54 @@ 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}"
|
||||||
if [ "$Email_successful" = "yes" -a "$nzbStatus" = 0 ]; then
|
replaceVarBy "${REPLACEDRESULT}" "<cat>" "${NZBPP_CATEGORY}"
|
||||||
|
replaceVarBy "${REPLACEDRESULT}" "<script>" "${script}"
|
||||||
|
Email_Message="${REPLACEDRESULT}"
|
||||||
|
for item in $Email_successful; do
|
||||||
|
if [ "${NZBPP_CATEGORY}" = "$item" -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; done
|
||||||
if [ "$Email_failed" = "yes" -a "$nzbStatus" != 0 ]; then
|
for item in $Email_failed; do
|
||||||
|
if [ "${NZBPP_CATEGORY}" = "$item" -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; done
|
||||||
exit $1
|
exit $1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if the script is called from nzbget
|
# Check if the script is called from nzbget 10.0 or later
|
||||||
if [ "$NZBPP_DIRECTORY" = "" -o "$NZBOP_CONFIGFILE" = "" ]; then
|
if [ "$NZBPP_DIRECTORY" = "" -o "$NZBOP_CONFIGFILE" = "" ]; then
|
||||||
echo "*** NZBGet post-process script ***"
|
echo "*** NZBGet post-processing script ***"
|
||||||
echo "This script is supposed to be called from nzbget (0.7.0 or later)."
|
echo "This script is supposed to be called from nzbget (10.0 or later)."
|
||||||
exit $POSTPROCESS_ERROR
|
exit $POSTPROCESS_ERROR
|
||||||
|
fi
|
||||||
|
if [ "$NZBOP_UNPACK" = "" ]; then
|
||||||
|
echo "[ERROR] This script requires nzbget version at least 10.0-testing-r555 or 10.0-stable."
|
||||||
|
exit $POSTPROCESS_ERROR
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if postprocessing was disabled in postprocessing parameters
|
# Check if postprocessing was disabled in postprocessing parameters
|
||||||
# (for current nzb-file) via web-interface or via command line with
|
# (for current nzb-file) via web-interface or via command line with
|
||||||
# "nzbget -E G O PostProcess=no <ID>"
|
# "nzbget -E G O PostProcess=no <ID>"
|
||||||
if [ "$NZBPR_PostProcess" = "no" ]; then
|
if [ "$NZBPR_PostProcess" = "no" ]; then
|
||||||
echo "[WARNING] Post-Process: Postprocessing disabled for this nzb-file, exiting"
|
echo "[WARNING] Post-Process: Post-processing disabled for this nzb-file, exiting"
|
||||||
exit $POSTPROCESS_NONE
|
exit $POSTPROCESS_NONE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -226,35 +232,25 @@ if [ "$NZBOP_ALLOWREPROCESS" = "yes" ]; then
|
||||||
BadConfig=1
|
BadConfig=1
|
||||||
fi
|
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
|
if [ "$BadConfig" -eq 1 ]; then
|
||||||
echo "[ERROR] Post-Process: Exiting because of not compatible nzbget configuration"
|
echo "[ERROR] Post-Process: Exiting due to incompatible nzbget configuration"
|
||||||
exit $POSTPROCESS_ERROR
|
exit $POSTPROCESS_ERROR
|
||||||
fi
|
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"
|
|
||||||
exit $POSTPROCESS_SUCCESS
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check par status
|
# Check par status
|
||||||
if [ "$NZBPP_PARSTATUS" -eq 1 -o "$NZBPP_PARSTATUS" -eq 3 -o "$NZBPP_PARFAILED" -eq 1 ]; then
|
if [ "$NZBPP_PARSTATUS" -eq 1 -o "$NZBPP_PARSTATUS" -eq 3 ]; then
|
||||||
if [ "$NZBPP_PARSTATUS" -eq 3 ]; then
|
if [ "$NZBPP_PARSTATUS" -eq 3 ]; then
|
||||||
echo "[WARNING] Post-Process: Par-check successful, but Par-repair disabled, exiting"
|
echo "[WARNING] Post-Process: Par-check successful, but Par-repair disabled, exiting"
|
||||||
else
|
else
|
||||||
echo "[WARNING] Post-Process: Par-check failed, exiting"
|
echo "[WARNING] Post-Process: Par-check failed, exiting"
|
||||||
fi
|
fi
|
||||||
do_exit $POSTPROCESS_ERROR
|
do_exit $POSTPROCESS_NONE
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check unpack status
|
||||||
|
if [ "$NZBPP_UNPACKSTATUS" -ne 2 ]; then
|
||||||
|
echo "[WARNING] Post-Process: Unpack failed or disabled, exiting"
|
||||||
|
do_exit $POSTPROCESS_NONE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if destination directory exists (important for reprocessing of history items)
|
# Check if destination directory exists (important for reprocessing of history items)
|
||||||
|
@ -265,96 +261,8 @@ fi
|
||||||
|
|
||||||
cd "$NZBPP_DIRECTORY"
|
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"
|
|
||||||
exit $POSTPROCESS_PARCHECK_ALL
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# All checks done, now processing the files
|
# 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"
|
|
||||||
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
|
# If download contains only nzb-files move them into nzb-directory
|
||||||
# for further download
|
# for further download
|
||||||
# Check if command "wc" exists
|
# Check if command "wc" exists
|
||||||
|
@ -375,10 +283,7 @@ chmod -R a+rw .
|
||||||
for word in $FileCleanUp ; do rm $word >/dev/null 2>&1 ; done
|
for word in $FileCleanUp ; do rm $word >/dev/null 2>&1 ; done
|
||||||
# Removed by default
|
# Removed by default
|
||||||
rm _brokenlog.txt >/dev/null 2>&1
|
rm _brokenlog.txt >/dev/null 2>&1
|
||||||
if [ "$Unrared" -eq 1 ]; then
|
rm *.[pP][aA][rR]2 >/dev/null 2>&1
|
||||||
# Delete par2-file only if there were files for unpacking.
|
|
||||||
rm *.[pP][aA][rR]2 >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$JoinTS" = "yes" ]; then
|
if [ "$JoinTS" = "yes" ]; then
|
||||||
# Join any split .ts files if they are named xxxx.0000.ts xxxx.0001.ts
|
# Join any split .ts files if they are named xxxx.0000.ts xxxx.0001.ts
|
||||||
|
@ -404,61 +309,6 @@ if [ "$RenameIMG" = "yes" ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
############################
|
|
||||||
### BEGIN CUSTOMIZATIONS ###
|
|
||||||
############################
|
|
||||||
|
|
||||||
# Move categories to /share/your_directory and remove download destination directory
|
|
||||||
# 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"
|
|
||||||
if [ "$?" -ne 0 ]; then
|
|
||||||
echo "[ERROR] Post-Process: Moving to $TvDownloadDir"
|
|
||||||
exit $POSTPROCESS_ERROR
|
|
||||||
else
|
|
||||||
rm -fr *
|
|
||||||
cd ..
|
|
||||||
rmdir "$NZBPP_DIRECTORY"
|
|
||||||
NZBPP_DIRECTORY="$TvDownloadDir"
|
|
||||||
cd "$NZBPP_DIRECTORY"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
# 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"
|
|
||||||
if [ "$?" -ne 0 ]; then
|
|
||||||
echo "[ERROR] Post-Process: Moving to $MoviesDownloadDir"
|
|
||||||
exit $POSTPROCESS_ERROR
|
|
||||||
else
|
|
||||||
rm -fr *
|
|
||||||
cd ..
|
|
||||||
rmdir "$NZBPP_DIRECTORY"
|
|
||||||
NZBPP_DIRECTORY="$MoviesDownloadDir"
|
|
||||||
cd "$NZBPP_DIRECTORY"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
# Test for category and ensure the passed directory exists as a directory.
|
|
||||||
if [ "$NZBPP_CATEGORY" = "$CustomCategory" -a -d "$CustomDownloadDir" ]; then
|
|
||||||
echo "[INFO] Post-Process: Moving $CustomCategory to $CustomDownloadDir"
|
|
||||||
cp -R "$NZBPP_DIRECTORY" "$CustomDownloadDir"
|
|
||||||
if [ "$?" -ne 0 ]; then
|
|
||||||
echo "[ERROR] Post-Process: Moving to $CustomDownloadDir"
|
|
||||||
exit $POSTPROCESS_ERROR
|
|
||||||
else
|
|
||||||
rm -fr *
|
|
||||||
cd ..
|
|
||||||
rmdir "$NZBPP_DIRECTORY"
|
|
||||||
NZBPP_DIRECTORY="$CustomDownloadDir"
|
|
||||||
cd "$NZBPP_DIRECTORY"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
##########################
|
|
||||||
### END CUSTOMIZATIONS ###
|
|
||||||
##########################
|
|
||||||
|
|
||||||
# Check if destination directory was set in postprocessing parameters
|
# Check if destination directory was set in postprocessing parameters
|
||||||
# (for current nzb-file) via web-interface or via command line with
|
# (for current nzb-file) via web-interface or via command line with
|
||||||
# "nzbget -E G O DestDir=/new/path <ID>"
|
# "nzbget -E G O DestDir=/new/path <ID>"
|
||||||
|
@ -467,8 +317,8 @@ if [ "$NZBPR_DestDir" != "" ]; then
|
||||||
mv * $NZBPR_DestDir >/dev/null 2>&1
|
mv * $NZBPR_DestDir >/dev/null 2>&1
|
||||||
cd ..
|
cd ..
|
||||||
rmdir $NZBPP_DIRECTORY
|
rmdir $NZBPP_DIRECTORY
|
||||||
NZBPP_DIRECTORY=$NZBPR_DestDir
|
NZBPP_DIRECTORY=$NZBPR_DestDir
|
||||||
cd "$NZBPP_DIRECTORY"
|
cd $NZBPP_DIRECTORY
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# All OK, requesting cleaning up of download queue
|
# All OK, requesting cleaning up of download queue
|
|
@ -102,6 +102,7 @@ nzbToMedia() {
|
||||||
PostProcessStatus=0
|
PostProcessStatus=0
|
||||||
if [ -n "$1" ]; then PostProcessStatus=$1 ; fi
|
if [ -n "$1" ]; then PostProcessStatus=$1 ; fi
|
||||||
if [ "$Debug" = "yes" ]; then echo "[DETAIL] Post-Process: comparing '$NZBPP_CATEGORY' to '$CouchPotatoCategory' and '$SickBeardCategory'" ; fi
|
if [ "$Debug" = "yes" ]; then echo "[DETAIL] Post-Process: comparing '$NZBPP_CATEGORY' to '$CouchPotatoCategory' and '$SickBeardCategory'" ; fi
|
||||||
|
find "$NZBPP_DIRECTORY" -type f -size -200000k -iname \*sample\* -exec rm {} \; >/dev/null 2>&1
|
||||||
if [ "$NZBPP_CATEGORY" = "$CouchPotatoCategory" ]; then
|
if [ "$NZBPP_CATEGORY" = "$CouchPotatoCategory" ]; then
|
||||||
if [ "$CouchPotato" = "yes" -a -e "$NzbToCouchPotato" ]; then
|
if [ "$CouchPotato" = "yes" -a -e "$NzbToCouchPotato" ]; then
|
||||||
script=$NzbToCouchPotato
|
script=$NzbToCouchPotato
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue