add printed return message. Fixes #493 Fixes #495 Fixes#496

This commit is contained in:
clinton-hall 2014-07-17 10:27:55 +09:30
commit de89fb2ce0
7 changed files with 71 additions and 64 deletions

View file

@ -56,7 +56,7 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
logger.error( logger.error(
'Category:[%s] is not defined or is not enabled. Please rename it or ensure it is enabled for the appropriate section in your autoProcessMedia.cfg and try again.' % ( 'Category:[%s] is not defined or is not enabled. Please rename it or ensure it is enabled for the appropriate section in your autoProcessMedia.cfg and try again.' % (
inputCategory)) inputCategory))
return -1 return [-1, ""]
else: else:
usercat = "ALL" usercat = "ALL"
@ -64,7 +64,7 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
logger.error( logger.error(
'Category:[%s] is not unique, %s are using it. Please rename it or disable all other sections using the same category name in your autoProcessMedia.cfg and try again.' % ( 'Category:[%s] is not unique, %s are using it. Please rename it or disable all other sections using the same category name in your autoProcessMedia.cfg and try again.' % (
usercat, section.keys())) usercat, section.keys()))
return -1 return [-1, ""]
if section: if section:
sectionName = section.keys()[0] sectionName = section.keys()[0]
@ -72,7 +72,7 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
else: else:
logger.error("Unable to locate a section with subsection:%s enabled in your autoProcessMedia.cfg, exiting!" % ( logger.error("Unable to locate a section with subsection:%s enabled in your autoProcessMedia.cfg, exiting!" % (
inputCategory)) inputCategory))
return -1 return [-1, ""]
try: try:
Torrent_NoLink = int(section[usercat]["Torrent_NoLink"]) Torrent_NoLink = int(section[usercat]["Torrent_NoLink"])
@ -105,7 +105,7 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
logger.error( logger.error(
'The output directory:[%s] is the Download Directory. Edit outputDirectory in autoProcessMedia.cfg. Exiting' % ( 'The output directory:[%s] is the Download Directory. Edit outputDirectory in autoProcessMedia.cfg. Exiting' % (
inputDirectory)) inputDirectory))
return -1 return [-1, ""]
logger.debug("Scanning files in directory: %s" % (inputDirectory)) logger.debug("Scanning files in directory: %s" % (inputDirectory))
@ -187,7 +187,7 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
logger.info("Calling %s:%s to post-process:%s" % (sectionName, usercat, inputName)) logger.info("Calling %s:%s to post-process:%s" % (sectionName, usercat, inputName))
result = 0 result = [ 0, "" ]
if sectionName == 'UserScript': if sectionName == 'UserScript':
result = external_script(outputDestination, inputName, inputCategory, section[usercat]) result = external_script(outputDestination, inputName, inputCategory, section[usercat])
@ -205,7 +205,7 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
elif sectionName == 'Gamez': elif sectionName == 'Gamez':
result = nzbtomedia.autoProcessGames().process(sectionName,outputDestination, inputName, status, clientAgent, inputCategory) result = nzbtomedia.autoProcessGames().process(sectionName,outputDestination, inputName, status, clientAgent, inputCategory)
if result != 0: if result[0] != 0:
if clientAgent != 'manual': if clientAgent != 'manual':
logger.error( logger.error(
"A problem was reported in the autoProcess* script. If torrent was paused we will resume seeding") "A problem was reported in the autoProcess* script. If torrent was paused we will resume seeding")
@ -240,7 +240,7 @@ def main(args):
logger.debug("Options passed into TorrentToMedia: %s" % (args)) logger.debug("Options passed into TorrentToMedia: %s" % (args))
# Post-Processing Result # Post-Processing Result
result = 0 result = [ 0, "" ]
try: try:
inputDirectory, inputName, inputCategory, inputHash, inputID = nzbtomedia.parse_args(clientAgent, args) inputDirectory, inputName, inputCategory, inputHash, inputID = nzbtomedia.parse_args(clientAgent, args)
@ -288,17 +288,17 @@ def main(args):
results = processTorrent(dirName, os.path.basename(dirName), subsection, inputHash, inputID, results = processTorrent(dirName, os.path.basename(dirName), subsection, inputHash, inputID,
clientAgent) clientAgent)
if results != 0: if results[0] != 0:
logger.error("A problem was reported when trying to perform a manual run for %s:%s." % ( logger.error("A problem was reported when trying to perform a manual run for %s:%s." % (
section, subsection)) section, subsection))
result = results result = results
if result == 0: if result[0] == 0:
logger.info("The %s script completed successfully." % (args[0])) logger.info("The %s script completed successfully." % (args[0]))
else: else:
logger.error("A problem was reported in the %s script." % (args[0])) logger.error("A problem was reported in the %s script." % (args[0]))
del nzbtomedia.MYAPP del nzbtomedia.MYAPP
return result return result[0]
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -499,7 +499,7 @@ def process(inputDirectory, inputName=None, status=0, clientAgent='manual', down
logger.error( logger.error(
'The input directory:[%s] is the Default Download Directory. Please configure category directories to prevent processing of other media.' % ( 'The input directory:[%s] is the Default Download Directory. Please configure category directories to prevent processing of other media.' % (
inputDirectory)) inputDirectory))
return -1 return [-1, ""]
if clientAgent != 'manual' and not nzbtomedia.DOWNLOADINFO: if clientAgent != 'manual' and not nzbtomedia.DOWNLOADINFO:
logger.debug('Adding NZB download info for directory %s to database' % (inputDirectory)) logger.debug('Adding NZB download info for directory %s to database' % (inputDirectory))
@ -530,7 +530,7 @@ def process(inputDirectory, inputName=None, status=0, clientAgent='manual', down
logger.error( logger.error(
'Category:[%s] is not defined or is not enabled. Please rename it or ensure it is enabled for the appropriate section in your autoProcessMedia.cfg and try again.' % ( 'Category:[%s] is not defined or is not enabled. Please rename it or ensure it is enabled for the appropriate section in your autoProcessMedia.cfg and try again.' % (
inputCategory)) inputCategory))
return -1 return [-1, ""]
else: else:
usercat = "ALL" usercat = "ALL"
@ -538,7 +538,7 @@ def process(inputDirectory, inputName=None, status=0, clientAgent='manual', down
logger.error( logger.error(
'Category:[%s] is not unique, %s are using it. Please rename it or disable all other sections using the same category name in your autoProcessMedia.cfg and try again.' % ( 'Category:[%s] is not unique, %s are using it. Please rename it or disable all other sections using the same category name in your autoProcessMedia.cfg and try again.' % (
inputCategory, section.keys())) inputCategory, section.keys()))
return -1 return [-1, ""]
if section: if section:
sectionName = section.keys()[0] sectionName = section.keys()[0]
@ -546,7 +546,7 @@ def process(inputDirectory, inputName=None, status=0, clientAgent='manual', down
else: else:
logger.error("Unable to locate a section with subsection:%s enabled in your autoProcessMedia.cfg, exiting!" % ( logger.error("Unable to locate a section with subsection:%s enabled in your autoProcessMedia.cfg, exiting!" % (
inputCategory)) inputCategory))
return -1 return [-1, ""]
try: try:
extract = int(section[usercat]['extract']) extract = int(section[usercat]['extract'])
@ -557,7 +557,7 @@ def process(inputDirectory, inputName=None, status=0, clientAgent='manual', down
if int(section[usercat]['remote_path']) and not nzbtomedia.REMOTEPATHS: if int(section[usercat]['remote_path']) and not nzbtomedia.REMOTEPATHS:
logger.error('Remote Path is enabled for %s:%s but no Network mount points are defined. Please check your autoProcessMedia.cfg, exiting!' % ( logger.error('Remote Path is enabled for %s:%s but no Network mount points are defined. Please check your autoProcessMedia.cfg, exiting!' % (
sectionName, inputCategory)) sectionName, inputCategory))
return -1 return [-1, ""]
except: except:
logger.error('Remote Path %s is not valid for %s:%s Please set this to either 0 to disable or 1 to enable!' % ( logger.error('Remote Path %s is not valid for %s:%s Please set this to either 0 to disable or 1 to enable!' % (
section[usercat]['remote_path'], sectionName, inputCategory)) section[usercat]['remote_path'], sectionName, inputCategory))
@ -586,9 +586,9 @@ def process(inputDirectory, inputName=None, status=0, clientAgent='manual', down
elif sectionName == 'UserScript': elif sectionName == 'UserScript':
result = external_script(inputDirectory, inputName, inputCategory, section[usercat]) result = external_script(inputDirectory, inputName, inputCategory, section[usercat])
else: else:
result = -1 result = [-1, ""]
if result == 0: if result[0] == 0:
if clientAgent != 'manual': if clientAgent != 'manual':
# update download status in our DB # update download status in our DB
update_downloadInfoStatus(inputName, 1) update_downloadInfoStatus(inputName, 1)
@ -614,7 +614,7 @@ def main(args, section=None):
logger.debug("Options passed into nzbToMedia: %s" % args) logger.debug("Options passed into nzbToMedia: %s" % args)
# Post-Processing Result # Post-Processing Result
result = 0 result = [0, ""]
status = 0 status = 0
# NZBGet # NZBGet
@ -729,23 +729,27 @@ def main(args, section=None):
results = process(dirName, os.path.basename(dirName), 0, clientAgent=clientAgent, results = process(dirName, os.path.basename(dirName), 0, clientAgent=clientAgent,
download_id=download_id, inputCategory=subsection) download_id=download_id, inputCategory=subsection)
if results != 0: if results[0] != 0:
logger.error("A problem was reported when trying to perform a manual run for %s:%s." % ( logger.error("A problem was reported when trying to perform a manual run for %s:%s." % (
section, subsection)) section, subsection))
result = results result = results
if result == 0: if result[0] == 0:
logger.info("The %s script completed successfully." % args[0]) logger.info("The %s script completed successfully." % args[0])
if result[1]:
print result[1] # For SABnzbd Status display.
if os.environ.has_key('NZBOP_SCRIPTDIR'): # return code for nzbget v11 if os.environ.has_key('NZBOP_SCRIPTDIR'): # return code for nzbget v11
del nzbtomedia.MYAPP del nzbtomedia.MYAPP
return (nzbtomedia.NZBGET_POSTPROCESS_SUCCESS) return (nzbtomedia.NZBGET_POSTPROCESS_SUCCESS)
else: else:
logger.error("A problem was reported in the %s script." % args[0]) logger.error("A problem was reported in the %s script." % args[0])
if result[1]:
print result[1] # For SABnzbd Status display.
if os.environ.has_key('NZBOP_SCRIPTDIR'): # return code for nzbget v11 if os.environ.has_key('NZBOP_SCRIPTDIR'): # return code for nzbget v11
del nzbtomedia.MYAPP del nzbtomedia.MYAPP
return (nzbtomedia.NZBGET_POSTPROCESS_ERROR) return (nzbtomedia.NZBGET_POSTPROCESS_ERROR)
del nzbtomedia.MYAPP del nzbtomedia.MYAPP
return (result) return (result[0])
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -11,7 +11,7 @@ class autoProcessComics:
def processEpisode(self, section, dirName, inputName=None, status=0, clientAgent='manual', inputCategory=None): def processEpisode(self, section, dirName, inputName=None, status=0, clientAgent='manual', inputCategory=None):
if int(status) != 0: if int(status) != 0:
logger.warning("FAILED DOWNLOAD DETECTED, nothing to process.",section) logger.warning("FAILED DOWNLOAD DETECTED, nothing to process.",section)
return 0 return [1, "%s: Failed to post-process. %s does not support failed downloads" % (section, section) ]
host = nzbtomedia.CFG[section][inputCategory]["host"] host = nzbtomedia.CFG[section][inputCategory]["host"]
port = nzbtomedia.CFG[section][inputCategory]["port"] port = nzbtomedia.CFG[section][inputCategory]["port"]
@ -58,18 +58,18 @@ class autoProcessComics:
r = requests.get(url, auth=(username, password), params=params, stream=True, verify=False) r = requests.get(url, auth=(username, password), params=params, stream=True, verify=False)
except requests.ConnectionError: except requests.ConnectionError:
logger.error("Unable to open URL", section) logger.error("Unable to open URL", section)
return 1 # failure return [1, "%s: Failed to post-process - Unable to connect to %s" % (section, section) ]
for line in r.iter_lines(): for line in r.iter_lines():
if line: logger.postprocess("%s" % (line), section) if line: logger.postprocess("%s" % (line), section)
if ("Post Processing SUCCESSFUL!" or "Post Processing SUCCESSFULL!")in line: success = True if ("Post Processing SUCCESSFUL!" or "Post Processing SUCCESSFULL!")in line: success = True
if not r.status_code in [requests.codes.ok, requests.codes.created, requests.codes.accepted]: if not r.status_code in [requests.codes.ok, requests.codes.created, requests.codes.accepted]:
logger.error("Server returned status %s" % (str(r.status_code)), section) logger.error("Server returned status %s" % (str(r.status_code)), section)
return 1 return [1, "%s: Failed to post-process - Server returned status %s" % (section, str(r.status_code)) ]
if success: if success:
logger.postprocess("SUCCESS: This issue has been processed successfully",section) logger.postprocess("SUCCESS: This issue has been processed successfully",section)
return 0 return [0, "%s: Successfully post-processed %s" % (section, inputName) ]
else: else:
logger.warning("The issue does not appear to have successfully processed. Please check your Logs",section) logger.warning("The issue does not appear to have successfully processed. Please check your Logs",section)
return 1 # failure return [1, "%s: Failed to post-process - Returned log from %s was not as expected." % (section, section) ]

View file

@ -54,7 +54,7 @@ class autoProcessGames:
r = requests.get(url, params=params, verify=False) r = requests.get(url, params=params, verify=False)
except requests.ConnectionError: except requests.ConnectionError:
logger.error("Unable to open URL") logger.error("Unable to open URL")
return 1 # failure return [1, "%s: Failed to post-process - Unable to connect to %s" % (section, section) ]
result = r.json() result = r.json()
logger.postprocess("%s" % (result),section) logger.postprocess("%s" % (result),section)
@ -64,17 +64,17 @@ class autoProcessGames:
shutil.move(dirName, os.path.join(library, inputName)) shutil.move(dirName, os.path.join(library, inputName))
except: except:
logger.error("Unable to move %s to %s" % (dirName, os.path.join(library, inputName)), section) logger.error("Unable to move %s to %s" % (dirName, os.path.join(library, inputName)), section)
return 1 return [1, "%s: Failed to post-process - Unable to move files" % (section) ]
else: else:
logger.error("No library specified to move files to. Please edit your configuration.", section) logger.error("No library specified to move files to. Please edit your configuration.", section)
return 1 return [1, "%s: Failed to post-process - No library defined in %s" % (section, section) ]
if not r.status_code in [requests.codes.ok, requests.codes.created, requests.codes.accepted]: if not r.status_code in [requests.codes.ok, requests.codes.created, requests.codes.accepted]:
logger.error("Server returned status %s" % (str(r.status_code)), section) logger.error("Server returned status %s" % (str(r.status_code)), section)
return 1 return [1, "%s: Failed to post-process - Server returned status %s" % (section, str(r.status_code)) ]
elif result['success']: elif result['success']:
logger.postprocess("SUCCESS: Status for %s has been set to %s in Gamez" % (gamezID, downloadStatus),section) logger.postprocess("SUCCESS: Status for %s has been set to %s in Gamez" % (gamezID, downloadStatus),section)
return 0 # Success return [0, "%s: Successfully post-processed %s" % (section, inputName) ]
else: else:
logger.error("FAILED: Status for %s has NOT been updated in Gamez" % (gamezID),section) logger.error("FAILED: Status for %s has NOT been updated in Gamez" % (gamezID),section)
return 1 # failure return [1, "%s: Failed to post-process - Returned log from %s was not as expected." % (section, section) ]

View file

@ -185,7 +185,7 @@ class autoProcessMovie:
status = 1 status = 1
elif clientAgent == "manual": elif clientAgent == "manual":
logger.warning("No media files found in directory %s to manually process." % (dirName), section) logger.warning("No media files found in directory %s to manually process." % (dirName), section)
return 0 # Success (as far as this script is concerned) return [0, ""] # Success (as far as this script is concerned)
else: else:
logger.warning("No media files found in directory %s. Processing this as a failed download" % (dirName), section) logger.warning("No media files found in directory %s. Processing this as a failed download" % (dirName), section)
status = 1 status = 1
@ -223,18 +223,18 @@ class autoProcessMovie:
r = requests.get(url, params=params, verify=False) r = requests.get(url, params=params, verify=False)
except requests.ConnectionError: except requests.ConnectionError:
logger.error("Unable to open URL", section) logger.error("Unable to open URL", section)
return 1 # failure return [1, "%s: Failed to post-process - Unable to connect to %s" % (section, section) ]
result = r.json() result = r.json()
if not r.status_code in [requests.codes.ok, requests.codes.created, requests.codes.accepted]: if not r.status_code in [requests.codes.ok, requests.codes.created, requests.codes.accepted]:
logger.error("Server returned status %s" % (str(r.status_code)), section) logger.error("Server returned status %s" % (str(r.status_code)), section)
return 1 return [1, "%s: Failed to post-process - Server returned status %s" % (section, str(r.status_code)) ]
elif result['success']: elif result['success']:
logger.postprocess("SUCCESS: Finished %s scan for folder %s" % (method, dirName), section) logger.postprocess("SUCCESS: Finished %s scan for folder %s" % (method, dirName), section)
else: else:
logger.error("FAILED: %s scan was unable to finish for folder %s. exiting!" % (method, dirName), logger.error("FAILED: %s scan was unable to finish for folder %s. exiting!" % (method, dirName),
section) section)
return 1 # failure return [1, "%s: Failed to post-process - Server did not return success" % (section) ]
else: else:
logger.postprocess("FAILED DOWNLOAD DETECTED FOR %s" % (inputName), section) logger.postprocess("FAILED DOWNLOAD DETECTED FOR %s" % (inputName), section)
@ -246,7 +246,7 @@ class autoProcessMovie:
if not download_id: if not download_id:
logger.error("Could not find a downloaded movie in the database matching %s, exiting!" % inputName, logger.error("Could not find a downloaded movie in the database matching %s, exiting!" % inputName,
section) section)
return 1 # failure return [1, "%s: Failed to post-process - Failed download not found in %s" % (section, section) ]
logger.postprocess("Setting failed release %s to ignored ..." % (inputName), section) logger.postprocess("Setting failed release %s to ignored ..." % (inputName), section)
@ -259,14 +259,17 @@ class autoProcessMovie:
r = requests.get(url, params=params, verify=False) r = requests.get(url, params=params, verify=False)
except requests.ConnectionError: except requests.ConnectionError:
logger.error("Unable to open URL %s" % (url), section) logger.error("Unable to open URL %s" % (url), section)
return 1 # failure return [1, "%s: Failed to post-process - Unable to connect to %s" % (section, section) ]
result = r.json() result = r.json()
if result['success']: if not r.status_code in [requests.codes.ok, requests.codes.created, requests.codes.accepted]:
logger.error("Server returned status %s" % (str(r.status_code)), section)
return [1, "%s: Failed to post-process - Server returned status %s" % (section, str(r.status_code)) ]
elif result['success']:
logger.postprocess("SUCCESS: %s has been set to ignored ..." % (inputName), section) logger.postprocess("SUCCESS: %s has been set to ignored ..." % (inputName), section)
else: else:
logger.warning("FAILED: Unable to set %s to ignored!" % (inputName), section) logger.warning("FAILED: Unable to set %s to ignored!" % (inputName), section)
return 1 return [1, "%s: Failed to post-process - Unable to set %s to ignored" % (section, inputName) ]
logger.postprocess("Trying to snatch the next highest ranked release.", section) logger.postprocess("Trying to snatch the next highest ranked release.", section)
@ -277,18 +280,18 @@ class autoProcessMovie:
r = requests.get(url, params={'media_id': media_id}) r = requests.get(url, params={'media_id': media_id})
except requests.ConnectionError: except requests.ConnectionError:
logger.error("Unable to open URL %s" % (url), section) logger.error("Unable to open URL %s" % (url), section)
return 1 # failure return [1, "%s: Failed to post-process - Unable to connect to %s" % (section, section) ]
result = r.json() result = r.json()
if not r.status_code in [requests.codes.ok, requests.codes.created, requests.codes.accepted]: if not r.status_code in [requests.codes.ok, requests.codes.created, requests.codes.accepted]:
logger.error("Server returned status %s" % (str(r.status_code)), section) logger.error("Server returned status %s" % (str(r.status_code)), section)
return 1 return [1, "%s: Failed to post-process - Server returned status %s" % (section, str(r.status_code)) ]
elif result['success']: elif result['success']:
logger.postprocess("SUCCESS: Snatched the next highest release ...", section) logger.postprocess("SUCCESS: Snatched the next highest release ...", section)
return 0 return [0, "%s: Successfully snatched next highest release" % (section) ]
else: else:
logger.postprocess("SUCCESS: Unable to find a new release to snatch now. CP will keep searching!", section) logger.postprocess("SUCCESS: Unable to find a new release to snatch now. CP will keep searching!", section)
return 0 # return [0, "%s: No new release found now. %s will keep searching" % (section, section) ]
# Added a releease that was not in the wanted list so confirm rename successful by finding this movie media.list. # Added a releease that was not in the wanted list so confirm rename successful by finding this movie media.list.
if not release: if not release:
@ -303,24 +306,24 @@ class autoProcessMovie:
try: try:
if release_id is None and release_status_old is None: # we didn't have a release before, but now we do. if release_id is None and release_status_old is None: # we didn't have a release before, but now we do.
logger.postprocess("SUCCESS: Movie %s has now been added to CouchPotato" % (imdbid), section) logger.postprocess("SUCCESS: Movie %s has now been added to CouchPotato" % (imdbid), section)
return 0 # success return [0, "%s: Successfully post-processed %s" % (section, inputName) ]
release_status_new = release[release_id]['status'] release_status_new = release[release_id]['status']
if release_status_new != release_status_old: if release_status_new != release_status_old:
logger.postprocess("SUCCESS: Release %s has now been marked with a status of [%s]" % ( logger.postprocess("SUCCESS: Release %s has now been marked with a status of [%s]" % (
inputName, str(release_status_new).upper()), section) inputName, str(release_status_new).upper()), section)
return 0 # success return [0, "%s: Successfully post-processed %s" % (section, inputName) ]
except: except:
pass pass
if not os.path.isdir(dirName): if not os.path.isdir(dirName):
logger.postprocess("SUCCESS: Input Directory [%s] has been processed and removed" % ( logger.postprocess("SUCCESS: Input Directory [%s] has been processed and removed" % (
dirName), section) dirName), section)
return 0 return [0, "%s: Successfully post-processed %s" % (section, inputName) ]
elif not listMediaFiles(dirName, media=True, audio=False, meta=False, archives=True): elif not listMediaFiles(dirName, media=True, audio=False, meta=False, archives=True):
logger.postprocess("SUCCESS: Input Directory [%s] has no remaining media files. This has been fully processed." % ( logger.postprocess("SUCCESS: Input Directory [%s] has no remaining media files. This has been fully processed." % (
dirName), section) dirName), section)
return 0 return [0, "%s: Successfully post-processed %s" % (section, inputName) ]
# pause and let CouchPotatoServer catch its breath # pause and let CouchPotatoServer catch its breath
time.sleep(10 * wait_for) time.sleep(10 * wait_for)
@ -329,4 +332,4 @@ class autoProcessMovie:
logger.warning( logger.warning(
"%s does not appear to have changed status after %s minutes, Please check your logs." % (inputName, wait_for), "%s does not appear to have changed status after %s minutes, Please check your logs." % (inputName, wait_for),
section) section)
return 1 # failure return [1, "%s: Failed to post-process - No change in status" % (section) ]

View file

@ -102,22 +102,22 @@ class autoProcessMusic:
r = requests.get(url, params=params, verify=False) r = requests.get(url, params=params, verify=False)
except requests.ConnectionError: except requests.ConnectionError:
logger.error("Unable to open URL %s" % (url) ,section) logger.error("Unable to open URL %s" % (url) ,section)
return 1 # failure return [1, "%s: Failed to post-process - Unable to connect to %s" % (section, section) ]
logger.debug("Result: %s" % (r.text),section) logger.debug("Result: %s" % (r.text),section)
if not r.status_code in [requests.codes.ok, requests.codes.created, requests.codes.accepted]: if not r.status_code in [requests.codes.ok, requests.codes.created, requests.codes.accepted]:
logger.error("Server returned status %s" % (str(r.status_code)), section) logger.error("Server returned status %s" % (str(r.status_code)), section)
return 1 return [1, "%s: Failed to post-process - Server returned status %s" % (section, str(r.status_code)) ]
elif r.text == "OK": elif r.text == "OK":
logger.postprocess("SUCCESS: Post-Processing started for %s in folder %s ..." % (inputName, dirName),section) logger.postprocess("SUCCESS: Post-Processing started for %s in folder %s ..." % (inputName, dirName),section)
else: else:
logger.error("FAILED: Post-Processing has NOT started for %s in folder %s. exiting!" % (inputName, dirName),section) logger.error("FAILED: Post-Processing has NOT started for %s in folder %s. exiting!" % (inputName, dirName),section)
return 1 # failure return [1, "%s: Failed to post-process - Returned log from %s was not as expected." % (section, section) ]
else: else:
logger.warning("FAILED DOWNLOAD DETECTED", section) logger.warning("FAILED DOWNLOAD DETECTED", section)
return 0 # Success (as far as this script is concerned) return [1, "%s: Failed to post-process. %s does not support failed downloads" % (section, section) ]
# we will now wait for this album to be processed before returning to TorrentToMedia and unpausing. # we will now wait for this album to be processed before returning to TorrentToMedia and unpausing.
timeout = time.time() + 60 * wait_for timeout = time.time() + 60 * wait_for
@ -125,12 +125,12 @@ class autoProcessMusic:
current_status = self.get_status(url, apikey, dirName) current_status = self.get_status(url, apikey, dirName)
if current_status is not None and current_status != release_status: # Something has changed. CPS must have processed this movie. if current_status is not None and current_status != release_status: # Something has changed. CPS must have processed this movie.
logger.postprocess("SUCCESS: This release is now marked as status [%s]" % (current_status),section) logger.postprocess("SUCCESS: This release is now marked as status [%s]" % (current_status),section)
return 0 return [0, "%s: Successfully post-processed %s" % (section, inputName) ]
if not os.path.isdir(dirName): if not os.path.isdir(dirName):
logger.postprocess("SUCCESS: The input directory %s has been removed Processing must have finished." % (dirName),section) logger.postprocess("SUCCESS: The input directory %s has been removed Processing must have finished." % (dirName),section)
return 0 return [0, "%s: Successfully post-processed %s" % (section, inputName) ]
time.sleep(10 * wait_for) time.sleep(10 * wait_for)
# The status hasn't changed. uTorrent can resume seeding now. # The status hasn't changed. uTorrent can resume seeding now.
logger.warning("The music album does not appear to have changed status after %s minutes. Please check your Logs" % (wait_for),section) logger.warning("The music album does not appear to have changed status after %s minutes. Please check your Logs" % (wait_for),section)
return 1 # failure return [1, "%s: Failed to post-process - No change in wanted status" % (section) ]

View file

@ -147,7 +147,7 @@ class autoProcessTV:
flatten(dirName) flatten(dirName)
elif clientAgent == "manual": elif clientAgent == "manual":
logger.warning("No media files found in directory %s to manually process." % (dirName), section) logger.warning("No media files found in directory %s to manually process." % (dirName), section)
return 0 # Success (as far as this script is concerned) return [0, ""] # Success (as far as this script is concerned)
else: else:
logger.warning("No media files found in directory %s. Processing this as a failed download" % (dirName), section) logger.warning("No media files found in directory %s. Processing this as a failed download" % (dirName), section)
status = 1 status = 1
@ -192,7 +192,7 @@ class autoProcessTV:
if delete_failed and os.path.isdir(dirName) and not os.path.dirname(dirName) == dirName: if delete_failed and os.path.isdir(dirName) and not os.path.dirname(dirName) == dirName:
logger.postprocess("Deleting failed files and folder %s" % (dirName), section) logger.postprocess("Deleting failed files and folder %s" % (dirName), section)
rmDir(dirName) rmDir(dirName)
return 0 # Success (as far as this script is concerned) return [1, "%s: Failed to post-process. %s does not support failed downloads" % (section, section) ] # Return as failed to flag this in the downloader.
if status == 0 and nzbtomedia.TRANSCODE == 1: # only transcode successful downlaods if status == 0 and nzbtomedia.TRANSCODE == 1: # only transcode successful downlaods
result, newDirName = transcoder.Transcode_directory(dirName) result, newDirName = transcoder.Transcode_directory(dirName)
@ -234,11 +234,11 @@ class autoProcessTV:
r = requests.post(url, data=data, headers=headers, stream=True, verify=False) r = requests.post(url, data=data, headers=headers, stream=True, verify=False)
except requests.ConnectionError: except requests.ConnectionError:
logger.error("Unable to open URL: %s" % (url), section) logger.error("Unable to open URL: %s" % (url), section)
return 1 # failure return [1, "%s: Failed to post-process - Unable to connect to %s" % (section, section) ]
if not r.status_code in [requests.codes.ok, requests.codes.created, requests.codes.accepted]: if not r.status_code in [requests.codes.ok, requests.codes.created, requests.codes.accepted]:
logger.error("Server returned status %s" % (str(r.status_code)), section) logger.error("Server returned status %s" % (str(r.status_code)), section)
return 1 return [1, "%s: Failed to post-process - Server returned status %s" % (section, str(r.status_code)) ]
Success = False Success = False
Started = False Started = False
@ -255,7 +255,7 @@ class autoProcessTV:
rmDir(dirName) rmDir(dirName)
if Success: if Success:
return 0 return [0, "%s: Successfully post-processed %s" % (section, inputName) ]
elif section == "NzbDrone" and Started: elif section == "NzbDrone" and Started:
n = 0 n = 0
current_numMissing = start_numMissing current_numMissing = start_numMissing
@ -277,12 +277,12 @@ class autoProcessTV:
logger.debug( logger.debug(
"The number of missing episodes changes from %s to %s and then remained the same for %s minutes. Consider this successful" % "The number of missing episodes changes from %s to %s and then remained the same for %s minutes. Consider this successful" %
(str(start_numMissing), str(current_numMissing), str(wait_for)), section) (str(start_numMissing), str(current_numMissing), str(wait_for)), section)
return 0 return [0, "%s: Successfully post-processed %s" % (section, inputName) ]
else: else:
# The status hasn't changed. we have waited 2 minutes which is more than enough. uTorrent can resume seeding now. # The status hasn't changed. we have waited 2 minutes which is more than enough. uTorrent can resume seeding now.
logger.warning( logger.warning(
"The number of missing episodes: %s does not appear to have changed status after %s minutes, Please check your logs." % "The number of missing episodes: %s does not appear to have changed status after %s minutes, Please check your logs." %
(str(start_numMissing), str(wait_for)), section) (str(start_numMissing), str(wait_for)), section)
return 1 return [1, "%s: Failed to post-process - No change in wanted status" % (section) ]
else: else:
return 1 # We did not receive Success confirmation. return [1, "%s: Failed to post-process - Returned log from %s was not as expected." % (section, section) ] # We did not receive Success confirmation.