From 12cce95d89bd61582df0566294df131cc48f71ee Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Fri, 8 Nov 2013 11:55:12 +1030 Subject: [PATCH] improve fork handling. #199 --- TorrentToMedia.py | 4 +-- autoProcess/autoProcessTV.py | 62 ++++++++++++------------------------ autoProcess/nzbToMediaEnv.py | 9 ++++++ 3 files changed, 31 insertions(+), 44 deletions(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index a04d3e5e..1cded274 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -36,8 +36,8 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID): extractionSuccess = False Logger.debug("MAIN: Received Directory: %s | Name: %s | Category: %s", inputDirectory, inputName, inputCategory) - if sbFork in ["TPB", "TPB-failed"] and inputCategory == sbCategory: - Logger.info("MAIN: Calling Sick-Beard to post-process: %s", inputName) + if inputCategory == sbCategory and sbFork in SICKBEARD_TORRENT: + Logger.info("MAIN: Calling SickBeard's %s branch to post-process: %s",sbFork ,inputName) result = autoProcessTV.processEpisode(inputDirectory, inputName, int(0)) if result == 1: Logger.info("MAIN: A problem was reported in the autoProcess* script. If torrent was pasued we will resume seeding") diff --git a/autoProcess/autoProcessTV.py b/autoProcess/autoProcessTV.py index 27b2c892..7c794f42 100644 --- a/autoProcess/autoProcessTV.py +++ b/autoProcess/autoProcessTV.py @@ -96,10 +96,10 @@ def processEpisode(dirName, nzbName=None, failed=False): mediaContainer = (config.get("Extensions", "mediaExtensions")).split(',') minSampleSize = int(config.get("Extensions", "minSampleSize")) - if not fork in ["TPB", "TPB-failed"]: + if not fork in SICKBEARD_TORRENT: process_all_exceptions(nzbName.lower(), dirName) - if nzbName != "Manual Run" and not fork in ["TPB", "TPB-failed"]: + if nzbName != "Manual Run" and not fork in SICKBEARD_TORRENT: # Now check if movie files exist in destination: video = int(0) for dirpath, dirnames, filenames in os.walk(dirName): @@ -125,49 +125,27 @@ def processEpisode(dirName, nzbName=None, failed=False): params = {} params['quiet'] = 1 - - # if you have specified you are using development branch from fork https://github.com/Tolstyak/Sick-Beard.git - if fork == "failed": + if fork in SICKBEARD_DIRNAME: params['dirName'] = dirName - if nzbName != None: - params['nzbName'] = nzbName - params['failed'] = failed - if status == 0: - Logger.info("The download succeeded. Sending process request to SickBeard's failed branch") - else: - Logger.info("The download failed. Sending 'failed' process request to SickBeard's failed branch") - - # if you have specified you are using development branch from fork https://github.com/Tolstyak/Sick-Beard.git - if fork in ["TPB", "TPB-failed"]: + else: params['dir'] = dirName - if nzbName != None: - params['nzbName'] = nzbName - if status == 0: - Logger.info("The download succeeded. Sending process request to SickBeard's TPB branch") - if fork == "TPB-failed": - params['failed'] = failed - elif fork == "TPB-failed": - Logger.info("The download failed. Sending 'failed' process request to SickBeard's TPB-failed branch") - params['failed'] = failed - else: - Logger.info("The download failed. Nothing to process") - if delete_failed and os.path.isdir(dirName) and not dirName in ['sys.argv[0]','/','']: - delete(dirName) - return 0 # Success (as far as this script is concerned) - # this is our default behaviour to work with the standard Master branch of SickBeard - elif fork == "default": - params['dir'] = dirName - if nzbName != None: - params['nzbName'] = nzbName - # the standard Master bamch of SickBeard cannot process failed downloads. So Exit here. - if status == 0: - Logger.info("The download succeeded. Sending process request to SickBeard") - else: - Logger.info("The download failed. Nothing to process") - if delete_failed and os.path.isdir(dirName) and not dirName in ['sys.argv[0]','/','']: - delete(dirName) - return 0 # Success (as far as this script is concerned) + if nzbName != None: + params['nzbName'] = nzbName + + if fork in SICKBEARD_FAILED: + params['failed'] = failed + + if status == 0: + Logger.info("The download succeeded. Sending process request to SickBeard's %s branch", fork) + elif fork in SICKBEARD_FAILED: + Logger.info("The download failed. Sending 'failed' process request to SickBeard's %s branch", fork) + else: + Logger.info("The download failed. SickBeard's %s branch does not handle failed downloads. Nothing to process", fork) + if delete_failed and os.path.isdir(dirName) and not dirName in ['sys.argv[0]','/','']: + Logger.info("Deleting directory: %s", dirName) + delete(dirName) + return 0 # Success (as far as this script is concerned) if status == 0 and transcode == 1: # only transcode successful downlaods result = Transcoder.Transcode_directory(dirName) diff --git a/autoProcess/nzbToMediaEnv.py b/autoProcess/nzbToMediaEnv.py index 6cf4dfe9..ca96309f 100644 --- a/autoProcess/nzbToMediaEnv.py +++ b/autoProcess/nzbToMediaEnv.py @@ -6,3 +6,12 @@ VERSION = 'V8.6' # Constants pertinant to SabNzb SABNZB_NO_OF_ARGUMENTS = 8 +# Constants pertaining to SickBeard Branches: +# extend this list to include all branches/forks that use "failed" to handle failed downloads. +SICKBEARD_FAILED = ["failed", "TPB-failed", "Pistachitos"] +# extend this list to include all branches/forks that use "dirName" not "dir" +SICKBEARD_DIRNAME = ["failed"] +# extend this list to include all branches/forks that process rar and link files for torrents and therefore skip extraction and linking in TorrentToMedia. +SICKBEARD_TORRENT = ["TPB", "TPB-failed", "Pistachitos"] + +