diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 1a11079e..2b0ecbc4 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -36,6 +36,13 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID): extractionSuccess = False Logger.debug("MAIN: Received Directory: %s | Name: %s | Category: %s", inputDirectory, inputName, inputCategory) + if sbFork == TPB and inputCategory == sbCategory: + Logger.info("MAIN: Calling Sick-Beard to post-process: %s", 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") + Logger.info("MAIN: All done.") + sys.exit() inputDirectory, inputName, inputCategory, root = category_search(inputDirectory, inputName, inputCategory, root, categories) # Confirm the category by parsing directory structure @@ -261,8 +268,8 @@ if __name__ == "__main__": uTorrentUSR = config.get("Torrent", "uTorrentUSR") # mysecretusr uTorrentPWD = config.get("Torrent", "uTorrentPWD") # mysecretpwr - TransmissionHost = config.get("Torrent", "TransmissionHost") # localhost - TransmissionPort = config.get("Torrent", "TransmissionPort") # 8084 + TransmissionHost = config.get("Torrent", "TransmissionHost") # localhost + TransmissionPort = config.get("Torrent", "TransmissionPort") # 8084 TransmissionUSR = config.get("Torrent", "TransmissionUSR") # mysecretusr TransmissionPWD = config.get("Torrent", "TransmissionPWD") # mysecretpwr @@ -275,6 +282,7 @@ if __name__ == "__main__": cpsCategory = config.get("CouchPotato", "cpsCategory") # movie sbCategory = config.get("SickBeard", "sbCategory") # tv + sbFork = config.get("SickBeard", "fork") # tv hpCategory = config.get("HeadPhones", "hpCategory") # music mlCategory = config.get("Mylar", "mlCategory") # comics gzCategory = config.get("Gamez", "gzCategory") # games diff --git a/autoProcess/autoProcessTV.py b/autoProcess/autoProcessTV.py index ba02a3ec..abf122d0 100644 --- a/autoProcess/autoProcessTV.py +++ b/autoProcess/autoProcessTV.py @@ -94,9 +94,9 @@ def processEpisode(dirName, nzbName=None, failed=False): watch_dir = "" try: - failed_fork = int(config.get("SickBeard", "failed_fork")) + fork = int(config.get("SickBeard", "fork")) except (ConfigParser.NoOptionError, ValueError): - failed_fork = 0 + fork = "default" try: transcode = int(config.get("Transcoder", "transcode")) @@ -116,9 +116,10 @@ def processEpisode(dirName, nzbName=None, failed=False): mediaContainer = (config.get("Extensions", "mediaExtensions")).split(',') minSampleSize = int(config.get("Extensions", "minSampleSize")) - process_all_exceptions(nzbName.lower(), dirName) + if fork != "TPB": + process_all_exceptions(nzbName.lower(), dirName) - if nzbName != "Manual Run": + if nzbName != "Manual Run" and fork != "TPB": # Now check if movie files exist in destination: video = int(0) for dirpath, dirnames, filenames in os.walk(dirName): @@ -146,7 +147,7 @@ def processEpisode(dirName, nzbName=None, failed=False): params['quiet'] = 1 # if you have specified you are using development branch from fork https://github.com/Tolstyak/Sick-Beard.git - if failed_fork: + if fork == "failed": params['dirName'] = dirName if nzbName != None: params['nzbName'] = nzbName @@ -156,9 +157,19 @@ def processEpisode(dirName, nzbName=None, failed=False): 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 == "TPB": + 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") # this is our default behaviour to work with the standard Master branch of SickBeard - else: + elif fork == "default": params['dir'] = dirName if nzbName != None: params['nzbName'] = nzbName diff --git a/autoProcess/migratecfg.py b/autoProcess/migratecfg.py index 2896a83b..5a598d50 100644 --- a/autoProcess/migratecfg.py +++ b/autoProcess/migratecfg.py @@ -54,6 +54,12 @@ def migrate(): option, value = item if option == "category": # change this old format option = "sbCategory" + if option == "failed_fork": # change this old format + option = "fork" + if int(value) == 1: + value = "failed" + else: + value = "default" if option == "outputDirectory": # move this to new location format value = os.path.split(os.path.normpath(value))[0] confignew.set("Torrent", option, value) @@ -242,8 +248,8 @@ def addnzbget(): section = "SickBeard" - envKeys = ['CATEGORY', 'HOST', 'PORT', 'USERNAME', 'PASSWORD', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'FAILED_FORK'] - cfgKeys = ['sbCategory', 'host', 'port', 'username', 'password', 'ssl', 'web_root', 'watch_dir', 'failed_fork'] + envKeys = ['CATEGORY', 'HOST', 'PORT', 'USERNAME', 'PASSWORD', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'FORK'] + cfgKeys = ['sbCategory', 'host', 'port', 'username', 'password', 'ssl', 'web_root', 'watch_dir', 'fork'] for index in range(len(envKeys)): key = 'NZBPO_SB' + envKeys[index] if os.environ.has_key(key): diff --git a/autoProcessMedia.cfg.sample b/autoProcessMedia.cfg.sample index 7a170fa7..c3f8d1f4 100644 --- a/autoProcessMedia.cfg.sample +++ b/autoProcessMedia.cfg.sample @@ -32,7 +32,7 @@ web_root = ssl = 0 delay = 0 watch_dir = -failed_fork = 0 +fork = default delete_failed = 0 diff --git a/nzbToMedia.py b/nzbToMedia.py index 650f082f..37df0cdf 100755 --- a/nzbToMedia.py +++ b/nzbToMedia.py @@ -92,10 +92,10 @@ # set this if SickBeard and nzbGet are on different systems. #sbwatch_dir= -# SickBeard uses failed fork (0, 1). +# SickBeard fork. # -# set to 1 if using the custom "failed fork". Default sickBeard uses 0. -#sbfailed_fork=0 +# set to default or TPB or failed if using the custom "TPB" or "failed fork". +#sbfork=default # SickBeard Delete Failed Downloads (0, 1) # diff --git a/nzbToSickBeard.py b/nzbToSickBeard.py index 4fd9752d..2f827194 100755 --- a/nzbToSickBeard.py +++ b/nzbToSickBeard.py @@ -46,10 +46,10 @@ # set this if SickBeard and nzbGet are on different systems. #sbwatch_dir= -# SickBeard uses failed fork (0, 1). +# SickBeard fork. # -# set to 1 if using the custom "failed fork". Default sickBeard uses 0. -#sbfailed_fork=0 +# set to default or TPB or failed if using the custom "TPB" or "failed fork". +#sbfork=default # SickBeard Delete Failed Downloads (0, 1). #