From 3b076a5cfa0a5ea41e561c6ec7b12cb65310abdf Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Mon, 8 Apr 2013 15:00:49 +0930 Subject: [PATCH] improve passing of download_id --- TorrentToMedia.py | 8 ++++- autoProcess/autoProcessMovie.py | 34 +++++++++++-------- autoProcess/nzbToMediaEnv.py | 4 +-- changelog.txt | 10 ++++++ nzbToCouchPotato.py | 4 ++- nzbToGamez.py | 2 ++ nzbToHeadPhones.py | 2 ++ nzbToMedia.py | 11 +++--- nzbToMylar.py | 2 ++ nzbToSickBeard.py | 2 ++ .../current-stable/nzbget-postprocess.sh | 16 +++++---- .../previous/nzbget-postprocess.sh | 10 ++++-- .../testing/nzbget-postprocess.sh | 16 +++++---- .../windows-builder/nzbget-postprocess.conf | 2 +- .../windows-builder/nzbget-postprocess.py | 12 +++++-- 15 files changed, 93 insertions(+), 42 deletions(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index d19c097c..3edf2333 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -170,7 +170,13 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID): if inputCategory == cpsCategory: Logger.info("MAIN: Calling CouchPotatoServer to post-process: %s", inputName) - result = autoProcessMovie.process(outputDestination, inputName, status, clientAgent, inputHash) + if clientAgent == 'utorrent' and inputHash != '': + download_id = 'uTorrent_' + inputHash + elif clientAgent == 'transmission' and inputHash != '': + download_id = 'Transmission_' + inputHash + else: + download_id = inputHash + result = autoProcessMovie.process(outputDestination, inputName, status, clientAgent, download_id) elif inputCategory == sbCategory: Logger.info("MAIN: Calling Sick-Beard to post-process: %s", inputName) result = autoProcessTV.processEpisode(outputDestination, inputName, status) diff --git a/autoProcess/autoProcessMovie.py b/autoProcess/autoProcessMovie.py index 89571fa8..f6405fc7 100644 --- a/autoProcess/autoProcessMovie.py +++ b/autoProcess/autoProcessMovie.py @@ -33,22 +33,27 @@ class AuthURLOpener(urllib.FancyURLopener): return urllib.FancyURLopener.open(self, url) def get_imdb(nzbName, dirName): - - a=nzbName.find('.cp(')+4 #search for .cptt( in nzbName - b=nzbName[a:].find(')')+a - imdbid=nzbName[a:b] + + imdbid = "" + + a = nzbName.find('.cp(') + 4 #search for .cptt( in nzbName + b = nzbName[a:].find(')') + a + if a > 3: # a == 3 if not exist + imdbid = nzbName[a:b] if imdbid: Logger.info("Found movie id %s in name", imdbid) return imdbid - a=dirName.find('.cp(')+4 #search for .cptt( in dirname - b=dirName[a:].find(')')+a - imdbid=dirName[a:b] + a = dirName.find('.cp(') + 4 #search for .cptt( in dirname + b = dirName[a:].find(')') + a + if a > 3: # a == 3 if not exist + imdbid = dirName[a:b] if imdbid: Logger.info("Found movie id %s in directory", imdbid) return imdbid + else: Logger.warning("Could not find an imdb id in directory or name") Logger.info("Postprocessing will continue, but the movie may not be identified correctly by CouchPotato") @@ -78,7 +83,7 @@ def get_movie_info(myOpener, baseURL, imdbid, download_id): if not imdbid: movieindex = [index for index in range(len(movieid)) if len(releases[index]) > 0] for index in movieindex: - releaseindex = [index2 for index2 in range(len(releases[index])) if len(releases[index][index2]) > 0 and "download_id" in releases[index][index2]["info"] and releases[index][index2]["info"]["download_id"] == download_id] + releaseindex = [index2 for index2 in range(len(releases[index])) if len(releases[index][index2]) > 0 and "download_id" in releases[index][index2]["info"] and releases[index][index2]["info"]["download_id"].lower() == download_id.lower()] if len(releaseindex) > 0: imdbid_list.append(library[index]) unique_imdbid_list = list(set(imdbid_list)) # convert this to a unique list to be sure we only have one imdbid @@ -124,8 +129,8 @@ def get_status(myOpener, baseURL, movie_id, clientAgent, download_id): try: release_status = "none" if download_id != "" and download_id != "none": # we have the download id from the downloader. Let's see if it's valid. - release_statuslist = [item["status"]["identifier"] for item in result["movie"]["releases"] if "download_id" in item["info"] and item["info"]["download_id"] == download_id] - clientAgentlist = [item["info"]["download_downloader"] for item in result["movie"]["releases"] if "download_id" in item["info"] and item["info"]["download_id"] == download_id] + release_statuslist = [item["status"]["identifier"] for item in result["movie"]["releases"] if "download_id" in item["info"] and item["info"]["download_id"].lower() == download_id.lower()] + clientAgentlist = [item["info"]["download_downloader"] for item in result["movie"]["releases"] if "download_id" in item["info"] and item["info"]["download_id"].lower() == download_id.lower()] if len(release_statuslist) == 1: # we have found a release by this id. :) release_status = release_statuslist[0] clientAgent = clientAgentlist[0] @@ -135,7 +140,7 @@ def get_status(myOpener, baseURL, movie_id, clientAgent, download_id): clients = [item for item in clientAgentlist if item.lower() == clientAgent.lower()] clientAgent = clients[0] if len(clients) == 1: # ok.. a unique entry for download_id and clientAgent ;) - release_status = [item["status"]["identifier"] for item in result["movie"]["releases"] if "download_id" in item["info"] and item["info"]["download_id"] == download_id and item["info"]["download_downloader"] == clientAgent][0] + release_status = [item["status"]["identifier"] for item in result["movie"]["releases"] if "download_id" in item["info"] and item["info"]["download_id"].lower() == download_id.lower() and item["info"]["download_downloader"] == clientAgent][0] Logger.debug("Found a single release for download_id: %s and clientAgent: %s. Release status is: %s", download_id, clientAgent, release_status) else: # doesn't matter. only really used as secondary confirmation of movie status change. Let's continue. Logger.debug("Found several releases for download_id: %s and clientAgent: %s. Cannot determine the release status", download_id, clientAgent) @@ -161,9 +166,10 @@ def get_status(myOpener, baseURL, movie_id, clientAgent, download_id): download_id = "none" release_status = "none" else: - index = [index for index in range(len(clientAgentlist)) if clientAgentlist[index] == clientAgent] + index = [index for index in range(len(clientAgentlist)) if clientAgentlist[index].lower() == clientAgent.lower()] if len(index) == 1: download_id = download_idlist[index[0]] + clientAgent = clientAgentlist[index[0]] release_status = "snatched" Logger.debug("Found download_id: %s for clientAgent: %s. Release status is: %s", download_id, clientAgent, release_status) else: @@ -269,9 +275,9 @@ def process(dirName, nzbName=None, status=0, clientAgent = "manual", download_id result = json.load(urlObj) Logger.info("CouchPotatoServer returned %s", result) if result['success']: - Logger.info("%s started on CouchPotatoServer for %s", command, nzbName) + Logger.info("%s scan started on CouchPotatoServer for %s", method, nzbName) else: - Logger.error("%s has NOT started on CouchPotatoServer for %s. Exiting", command, nzbName) + Logger.error("%s scan has NOT started on CouchPotatoServer for %s. Exiting", method, nzbName) return 1 # failure else: diff --git a/autoProcess/nzbToMediaEnv.py b/autoProcess/nzbToMediaEnv.py index 845f9d11..1b9fddd8 100644 --- a/autoProcess/nzbToMediaEnv.py +++ b/autoProcess/nzbToMediaEnv.py @@ -1,10 +1,10 @@ # Make things easy and less error prone by centralising all common values # Global Constants -VERSION = 'V7.1' +VERSION = 'V7.2' # Constants pertinant to SabNzb SABNZB_NO_OF_ARGUMENTS = 8 # Constants pertinant to NzbGet -NZBGET_NO_OF_ARGUMENTS = 5 +NZBGET_NO_OF_ARGUMENTS = 6 diff --git a/changelog.txt b/changelog.txt index 0a3a2281..25850667 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,15 @@ Change_LOG / History +V7.2 XX/04/2013 + +Impacts All +Added download_id pass through for CouchPotato release matching +Uses single directory scanning for CouchPotato renamer +Matches imdb_id, download_id, clientAgent with CPS database + +Impacts NZB +Fixed TLS support for NZBGet email notifications + V7.1 28/03/2013 Impacts Torrents diff --git a/nzbToCouchPotato.py b/nzbToCouchPotato.py index 23306e6d..bfad066f 100755 --- a/nzbToCouchPotato.py +++ b/nzbToCouchPotato.py @@ -39,9 +39,11 @@ elif len(sys.argv) == NZBGET_NO_OF_ARGUMENTS: # 1 The final directory of the job (full path) # 2 The original name of the NZB file # 3 The status of the download: 0 == successful + # 4 The category of the download: + # 5 The download_id Logger.info("Script triggered from NZBGet, starting autoProcessMovie...") clientAgent = "nzbget" - result = autoProcessMovie.process(sys.argv[1], sys.argv[2], sys.argv[3], clientAgent) + result = autoProcessMovie.process(sys.argv[1], sys.argv[2], sys.argv[3], clientAgent, sys.argv[5]) else: Logger.warn("Invalid number of arguments received from client.") Logger.info("Running autoProcessMovie as a manual run...") diff --git a/nzbToGamez.py b/nzbToGamez.py index d37d1f51..72a247e8 100755 --- a/nzbToGamez.py +++ b/nzbToGamez.py @@ -38,6 +38,8 @@ elif len(sys.argv) == NZBGET_NO_OF_ARGUMENTS: # 1 The final directory of the job (full path) # 2 The original name of the NZB file # 3 The status of the download: 0 == successful + # 4 The category of the download: + # 5 The download_id Logger.info("Script triggered from NZBGet, starting autoProcessGames...") result = autoProcessGames.process(sys.argv[1], sys.argv[2], sys.argv[3]) else: diff --git a/nzbToHeadPhones.py b/nzbToHeadPhones.py index b32178a8..f6368006 100755 --- a/nzbToHeadPhones.py +++ b/nzbToHeadPhones.py @@ -38,6 +38,8 @@ elif len(sys.argv) == NZBGET_NO_OF_ARGUMENTS: # 1 The final directory of the job (full path) # 2 The original name of the NZB file # 3 The status of the download: 0 == successful + # 4 The category of the download: + # 5 The download_id Logger.info("Script triggered from NZBGet, starting autoProcessMusic...") result = autoProcessMusic.process(sys.argv[1], sys.argv[2], sys.argv[3]) else: diff --git a/nzbToMedia.py b/nzbToMedia.py index 40076000..0ede30fb 100755 --- a/nzbToMedia.py +++ b/nzbToMedia.py @@ -51,26 +51,27 @@ if len(sys.argv) == SABNZB_NO_OF_ARGUMENTS: # 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2 Logger.info("MAIN: Script triggered from SABnzbd") clientAgent = "sabnzbd" - nzbDir, inputName, status, inputCategory = (sys.argv[1], sys.argv[2], sys.argv[7], sys.argv[5]) + nzbDir, inputName, status, inputCategory, download_id = (sys.argv[1], sys.argv[2], sys.argv[7], sys.argv[5], '') # NZBGet elif len(sys.argv) == NZBGET_NO_OF_ARGUMENTS: # NZBGet argv: # 1 The final directory of the job (full path) # 2 The original name of the NZB file # 3 The status of the download: 0 == successful - # 4 User-defined category + # 4 The category of the download: + # 5 The download_id Logger.info("MAIN: Script triggered from NZBGet") clientAgent = "nzbget" - nzbDir, inputName, status, inputCategory = (sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]) + nzbDir, inputName, status, inputCategory, download_id = (sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5]) else: # only CPS supports this manual run for now. Logger.warn("MAIN: Invalid number of arguments received from client.") Logger.info("MAIN: Running autoProcessMovie as a manual run...") clientAgent = "manual" - nzbDir, inputName, status, inputCategory = ('Manual Run', 'Manual Run', 0, cpsCategory) + nzbDir, inputName, status, inputCategory, download_id = ('Manual Run', 'Manual Run', 0, cpsCategory, '') if inputCategory == cpsCategory: Logger.info("MAIN: Calling CouchPotatoServer to post-process: %s", inputName) - result = autoProcessMovie.process(nzbDir, inputName, status, clientAgent) + result = autoProcessMovie.process(nzbDir, inputName, status, clientAgent, download_id) elif inputCategory == sbCategory: Logger.info("MAIN: Calling Sick-Beard to post-process: %s", inputName) result = autoProcessTV.processEpisode(nzbDir, inputName, status) diff --git a/nzbToMylar.py b/nzbToMylar.py index e3624653..6e9eca4b 100755 --- a/nzbToMylar.py +++ b/nzbToMylar.py @@ -38,6 +38,8 @@ elif len(sys.argv) == NZBGET_NO_OF_ARGUMENTS: # 1 The final directory of the job (full path) # 2 The original name of the NZB file # 3 The status of the download: 0 == successful + # 4 The category of the download: + # 5 The download_id Logger.info("Script triggered from NZBGet, starting autoProcessComics...") result = autoProcessComics.processEpisode(sys.argv[1], sys.argv[2], sys.argv[3]) else: diff --git a/nzbToSickBeard.py b/nzbToSickBeard.py index 2a22ef47..b7daf1eb 100755 --- a/nzbToSickBeard.py +++ b/nzbToSickBeard.py @@ -60,6 +60,8 @@ elif len(sys.argv) == NZBGET_NO_OF_ARGUMENTS: # 1 The final directory of the job (full path) # 2 The original name of the NZB file # 3 The status of the download: 0 == successful + # 4 The category of the download: + # 5 The download_id Logger.info("Script triggered from NZBGet, starting autoProcessTV...") result = autoProcessTV.processEpisode(sys.argv[1], sys.argv[2], sys.argv[3]) else: diff --git a/nzbget-postprocessing-files/current-stable/nzbget-postprocess.sh b/nzbget-postprocessing-files/current-stable/nzbget-postprocess.sh index a8bed4e3..795237d8 100755 --- a/nzbget-postprocessing-files/current-stable/nzbget-postprocess.sh +++ b/nzbget-postprocessing-files/current-stable/nzbget-postprocess.sh @@ -82,9 +82,13 @@ nzbToMedia() { if [ -n "$1" ]; then PostProcessStatus=$1 ; fi if [ "$Debug" = "yes" ]; then echo "[DETAIL] Post-Process: comparing '$NZBPP_CATEGORY' to '$CouchPotatoCategory' and '$SickBeardCategory'" | tee -a $tmplog; fi find "$NZBPP_DIRECTORY" -type f -size -200000k -iname \*sample\* -exec rm {} \; >/dev/null 2>&1 + download_id="" if [ "$NZBPP_CATEGORY" = "$CouchPotatoCategory" ]; then if [ "$CouchPotato" = "yes" -a -e "$NzbToCouchPotato" ]; then script=$NzbToCouchPotato + if [ $NZBPR_couchpotato ]; then + download_id=$NZBPR_couchpotato + fi # Call Couchpotato's postprocessing script echo "[INFO] Post-Process: Running CouchPotato's postprocessing script" | tee -a $tmplog if [ "$Debug" = "yes" ]; then @@ -93,7 +97,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 replaceLogLine "${line}" ; fi ; done + $PythonCmd $NzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" "$download_id" | 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 @@ -110,7 +114,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 replaceLogLine "${line}" ; fi ; done + $PythonCmd $NzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" "$download_id" | 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 @@ -127,7 +131,7 @@ nzbToMedia() { echo "[DETAIL] Post-Process: HeadPhones-Script-ARGV2=$NZBPP_NZBFILENAME" | tee -a $tmplog echo "[DETAIL] Post-Process: HeadPhones-Script-ARGV3=$PostProcessStatus" | tee -a $tmplog fi - $PythonCmd $NzbToHeadPhones "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" | while read line ; do if [ "$line" != "" ] ; then replaceLogLine "${line}" ; fi ; done + $PythonCmd $NzbToHeadPhones "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" "$download_id" | while read line ; do if [ "$line" != "" ] ; then replaceLogLine "${line}" ; fi ; done else if [ "$HeadPhones" != "yes" ]; then echo "[DETAIL] Post-Process: Ignored to run HeadPhones' postprocessing script as it is disabled by user ('$HeadPhones')" | tee -a $tmplog; fi if [ ! -e "$NzbToHeadPhones" ]; then echo "[DETAIL] Post-Process: Ignored to run HeadPhones' postprocessing script as the specified script ('$NzbToHeadPhones') does not exist" | tee -a $tmplog; fi @@ -144,7 +148,7 @@ nzbToMedia() { echo "[DETAIL] Post-Process: Mylar-Script-ARGV2=$NZBPP_NZBFILENAME" | tee -a $tmplog echo "[DETAIL] Post-Process: Mylar-Script-ARGV3=$PostProcessStatus" | tee -a $tmplog fi - $PythonCmd $NzbToMylar "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" | while read line ; do if [ "$line" != "" ] ; then replaceLogLine "${line}" ; fi ; done + $PythonCmd $NzbToMylar "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" "$download_id" | while read line ; do if [ "$line" != "" ] ; then replaceLogLine "${line}" ; fi ; done else if [ "$Mylar" != "yes" ]; then echo "[DETAIL] Post-Process: Ignored to run Mylar's postprocessing script as it is disabled by user ('$Mylar')" | tee -a $tmplog; fi if [ ! -e "$NzbToMylar" ]; then echo "[DETAIL] Post-Process: Ignored to run Mylar's postprocessing script as the specified script ('$NzbToMylar') does not exist" | tee -a $tmplog; fi @@ -161,7 +165,7 @@ nzbToMedia() { echo "[DETAIL] Post-Process: Gamez-Script-ARGV2=$NZBPP_NZBFILENAME" | tee -a $tmplog echo "[DETAIL] Post-Process: Gamez-Script-ARGV3=$PostProcessStatus" | tee -a $tmplog fi - $PythonCmd $NzbToGamez "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" | while read line ; do if [ "$line" != "" ] ; then replaceLogLine "${line}" ; fi ; done + $PythonCmd $NzbToGamez "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" "$download_id" | while read line ; do if [ "$line" != "" ] ; then replaceLogLine "${line}" ; fi ; done else if [ "$Gamez" != "yes" ]; then echo "[DETAIL] Post-Process: Ignored to run Gamez's postprocessing script as it is disabled by user ('$Gamez')" | tee -a $tmplog; fi if [ ! -e "$NzbToGamez" ]; then echo "[DETAIL] Post-Process: Ignored to run Gamez's postprocessing script as the specified script ('$NzbToGamez') does not exist" | tee -a $tmplog; fi @@ -178,7 +182,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 replaceLogLine "${line}" ; fi ; done + $CustomCmd $CustomScript "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" "$download_id" | 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 diff --git a/nzbget-postprocessing-files/previous/nzbget-postprocess.sh b/nzbget-postprocessing-files/previous/nzbget-postprocess.sh index 0b6b54a0..f5ad617c 100644 --- a/nzbget-postprocessing-files/previous/nzbget-postprocess.sh +++ b/nzbget-postprocessing-files/previous/nzbget-postprocess.sh @@ -103,9 +103,13 @@ nzbToMedia() { if [ -n "$1" ]; then PostProcessStatus=$1 ; fi if [ "$Debug" = "yes" ]; then echo "[DETAIL] Post-Process: comparing '$NZBPP_CATEGORY' to '$CouchPotatoCategory' and '$SickBeardCategory'" | tee -a $tmplog; fi find "$NZBPP_DIRECTORY" -type f -size -200000k -iname \*sample\* -exec rm {} \; >/dev/null 2>&1 + download_id="" if [ "$NZBPP_CATEGORY" = "$CouchPotatoCategory" ]; then if [ "$CouchPotato" = "yes" -a -e "$NzbToCouchPotato" ]; then script=$NzbToCouchPotato + if [ $NZBPR_couchpotato ]; then + download_id=$NZBPR_couchpotato + fi # Call Couchpotato's postprocessing script echo "[INFO] Post-Process: Running CouchPotato's postprocessing script" | tee -a $tmplog if [ "$Debug" = "yes" ]; then @@ -114,7 +118,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 replaceLogLine "${line}" ; fi ; done + $PythonCmd $NzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" "$download_id" | 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 +135,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 replaceLogLine "${line}" ; fi ; done + $PythonCmd $NzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" "$download_id" | 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 +152,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 replaceLogLine "${line}" ; fi ; done + $CustomCmd $CustomScript "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" "$download_id" | 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 diff --git a/nzbget-postprocessing-files/testing/nzbget-postprocess.sh b/nzbget-postprocessing-files/testing/nzbget-postprocess.sh index a8bed4e3..795237d8 100755 --- a/nzbget-postprocessing-files/testing/nzbget-postprocess.sh +++ b/nzbget-postprocessing-files/testing/nzbget-postprocess.sh @@ -82,9 +82,13 @@ nzbToMedia() { if [ -n "$1" ]; then PostProcessStatus=$1 ; fi if [ "$Debug" = "yes" ]; then echo "[DETAIL] Post-Process: comparing '$NZBPP_CATEGORY' to '$CouchPotatoCategory' and '$SickBeardCategory'" | tee -a $tmplog; fi find "$NZBPP_DIRECTORY" -type f -size -200000k -iname \*sample\* -exec rm {} \; >/dev/null 2>&1 + download_id="" if [ "$NZBPP_CATEGORY" = "$CouchPotatoCategory" ]; then if [ "$CouchPotato" = "yes" -a -e "$NzbToCouchPotato" ]; then script=$NzbToCouchPotato + if [ $NZBPR_couchpotato ]; then + download_id=$NZBPR_couchpotato + fi # Call Couchpotato's postprocessing script echo "[INFO] Post-Process: Running CouchPotato's postprocessing script" | tee -a $tmplog if [ "$Debug" = "yes" ]; then @@ -93,7 +97,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 replaceLogLine "${line}" ; fi ; done + $PythonCmd $NzbToCouchPotato "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" "$download_id" | 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 @@ -110,7 +114,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 replaceLogLine "${line}" ; fi ; done + $PythonCmd $NzbToSickBeard "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" "$download_id" | 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 @@ -127,7 +131,7 @@ nzbToMedia() { echo "[DETAIL] Post-Process: HeadPhones-Script-ARGV2=$NZBPP_NZBFILENAME" | tee -a $tmplog echo "[DETAIL] Post-Process: HeadPhones-Script-ARGV3=$PostProcessStatus" | tee -a $tmplog fi - $PythonCmd $NzbToHeadPhones "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" | while read line ; do if [ "$line" != "" ] ; then replaceLogLine "${line}" ; fi ; done + $PythonCmd $NzbToHeadPhones "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" "$download_id" | while read line ; do if [ "$line" != "" ] ; then replaceLogLine "${line}" ; fi ; done else if [ "$HeadPhones" != "yes" ]; then echo "[DETAIL] Post-Process: Ignored to run HeadPhones' postprocessing script as it is disabled by user ('$HeadPhones')" | tee -a $tmplog; fi if [ ! -e "$NzbToHeadPhones" ]; then echo "[DETAIL] Post-Process: Ignored to run HeadPhones' postprocessing script as the specified script ('$NzbToHeadPhones') does not exist" | tee -a $tmplog; fi @@ -144,7 +148,7 @@ nzbToMedia() { echo "[DETAIL] Post-Process: Mylar-Script-ARGV2=$NZBPP_NZBFILENAME" | tee -a $tmplog echo "[DETAIL] Post-Process: Mylar-Script-ARGV3=$PostProcessStatus" | tee -a $tmplog fi - $PythonCmd $NzbToMylar "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" | while read line ; do if [ "$line" != "" ] ; then replaceLogLine "${line}" ; fi ; done + $PythonCmd $NzbToMylar "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" "$download_id" | while read line ; do if [ "$line" != "" ] ; then replaceLogLine "${line}" ; fi ; done else if [ "$Mylar" != "yes" ]; then echo "[DETAIL] Post-Process: Ignored to run Mylar's postprocessing script as it is disabled by user ('$Mylar')" | tee -a $tmplog; fi if [ ! -e "$NzbToMylar" ]; then echo "[DETAIL] Post-Process: Ignored to run Mylar's postprocessing script as the specified script ('$NzbToMylar') does not exist" | tee -a $tmplog; fi @@ -161,7 +165,7 @@ nzbToMedia() { echo "[DETAIL] Post-Process: Gamez-Script-ARGV2=$NZBPP_NZBFILENAME" | tee -a $tmplog echo "[DETAIL] Post-Process: Gamez-Script-ARGV3=$PostProcessStatus" | tee -a $tmplog fi - $PythonCmd $NzbToGamez "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" | while read line ; do if [ "$line" != "" ] ; then replaceLogLine "${line}" ; fi ; done + $PythonCmd $NzbToGamez "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" "$download_id" | while read line ; do if [ "$line" != "" ] ; then replaceLogLine "${line}" ; fi ; done else if [ "$Gamez" != "yes" ]; then echo "[DETAIL] Post-Process: Ignored to run Gamez's postprocessing script as it is disabled by user ('$Gamez')" | tee -a $tmplog; fi if [ ! -e "$NzbToGamez" ]; then echo "[DETAIL] Post-Process: Ignored to run Gamez's postprocessing script as the specified script ('$NzbToGamez') does not exist" | tee -a $tmplog; fi @@ -178,7 +182,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 replaceLogLine "${line}" ; fi ; done + $CustomCmd $CustomScript "$NZBPP_DIRECTORY" "$NZBPP_NZBFILENAME" "$PostProcessStatus" "$NZBPP_CATEGORY" "$download_id" | 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 diff --git a/nzbget-postprocessing-files/windows-builder/nzbget-postprocess.conf b/nzbget-postprocessing-files/windows-builder/nzbget-postprocess.conf index b0927a32..475a26bf 100644 --- a/nzbget-postprocessing-files/windows-builder/nzbget-postprocess.conf +++ b/nzbget-postprocessing-files/windows-builder/nzbget-postprocess.conf @@ -119,7 +119,7 @@ Email_To= Email_Server= # Server uses tsl (auto, yes, no). -Tsl=auto +Tls=auto # Enter your smtp server user name (if required) Email_User= diff --git a/nzbget-postprocessing-files/windows-builder/nzbget-postprocess.py b/nzbget-postprocessing-files/windows-builder/nzbget-postprocess.py index 1d391a24..ec10ec2b 100644 --- a/nzbget-postprocessing-files/windows-builder/nzbget-postprocess.py +++ b/nzbget-postprocessing-files/windows-builder/nzbget-postprocess.py @@ -83,7 +83,7 @@ def nzbToMedia(nzbStatus): Logger.debug("Post-Process: CouchPotato-Script-ARGV1= %s", NZBPP_DIRECTORY) Logger.debug("Post-Process: CouchPotato-Script-ARGV2= %s", NZBPP_NZBFILENAME) Logger.debug("Post-Process: CouchPotato-Script-ARGV3= %s", PostProcessStatus) - result = autoProcessMovie.process(NZBPP_DIRECTORY, NZBPP_NZBFILENAME, PostProcessStatus) + result = autoProcessMovie.process(NZBPP_DIRECTORY, NZBPP_NZBFILENAME, PostProcessStatus, clientAgent, download_id) else: Logger.debug("Post-Process: Ignored to run CouchPotato's postprocessing script as it is disabled by user") @@ -188,7 +188,7 @@ def do_exit(Process_Code): if line != "": Email_Message2 = Email_Message2 + "\r\n" + line f.close() - command = [sendEmail, "-f", Email_From, "-t", Email_To, "-s", Email_Server, "-o", "tsl=" + Tsl] + command = [sendEmail, "-f", Email_From, "-t", Email_To, "-s", Email_Server, "-o", "tls=" + Tls] if Email_User != "" and Email_Pass != "": command.append("-xu") command.append(Email_User) @@ -211,7 +211,7 @@ def do_exit(Process_Code): if line != "": Email_Message2 = Email_Message2 + "\r\n" + line f.close() - command = [sendEmail, "-f", Email_From, "-t", Email_To, "-s", Email_Server, "-o", "tsl=" + Tsl] + command = [sendEmail, "-f", Email_From, "-t", Email_To, "-s", Email_Server, "-o", "tls=" + Tls] if Email_User != "" and Email_Pass != "": command.append("-xu") command.append(Email_User) @@ -276,6 +276,12 @@ NZBPR_PostProcess = os.getenv('NZBPR_PostProcess') NZBPR_DestDir = os.getenv('NZBPR_DestDir') NZBOP_ALLOWREPROCESS = os.getenv('NZBOP_ALLOWREPROCESS') +clientAgent = "nzbget" +try: + download_id = os.getenv('NZBPR_couchpotato') +except: + download_id = "" + # Name of script's configuration file SCRIPT_CONFIG_FILE = "nzbget-postprocess.conf"