improve fork handling. #199

This commit is contained in:
clinton-hall 2013-11-08 11:55:12 +10:30
commit 12cce95d89
3 changed files with 31 additions and 44 deletions

View file

@ -36,8 +36,8 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
extractionSuccess = False extractionSuccess = False
Logger.debug("MAIN: Received Directory: %s | Name: %s | Category: %s", inputDirectory, inputName, inputCategory) Logger.debug("MAIN: Received Directory: %s | Name: %s | Category: %s", inputDirectory, inputName, inputCategory)
if sbFork in ["TPB", "TPB-failed"] and inputCategory == sbCategory: if inputCategory == sbCategory and sbFork in SICKBEARD_TORRENT:
Logger.info("MAIN: Calling Sick-Beard to post-process: %s", inputName) Logger.info("MAIN: Calling SickBeard's %s branch to post-process: %s",sbFork ,inputName)
result = autoProcessTV.processEpisode(inputDirectory, inputName, int(0)) result = autoProcessTV.processEpisode(inputDirectory, inputName, int(0))
if result == 1: 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: A problem was reported in the autoProcess* script. If torrent was pasued we will resume seeding")

View file

@ -96,10 +96,10 @@ def processEpisode(dirName, nzbName=None, failed=False):
mediaContainer = (config.get("Extensions", "mediaExtensions")).split(',') mediaContainer = (config.get("Extensions", "mediaExtensions")).split(',')
minSampleSize = int(config.get("Extensions", "minSampleSize")) 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) 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: # Now check if movie files exist in destination:
video = int(0) video = int(0)
for dirpath, dirnames, filenames in os.walk(dirName): for dirpath, dirnames, filenames in os.walk(dirName):
@ -125,49 +125,27 @@ def processEpisode(dirName, nzbName=None, failed=False):
params = {} params = {}
params['quiet'] = 1 params['quiet'] = 1
if fork in SICKBEARD_DIRNAME:
# if you have specified you are using development branch from fork https://github.com/Tolstyak/Sick-Beard.git
if fork == "failed":
params['dirName'] = dirName params['dirName'] = dirName
if nzbName != None: else:
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"]:
params['dir'] = dirName 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 if nzbName != None:
elif fork == "default": params['nzbName'] = nzbName
params['dir'] = dirName
if nzbName != None: if fork in SICKBEARD_FAILED:
params['nzbName'] = nzbName params['failed'] = failed
# the standard Master bamch of SickBeard cannot process failed downloads. So Exit here.
if status == 0: if status == 0:
Logger.info("The download succeeded. Sending process request to SickBeard") Logger.info("The download succeeded. Sending process request to SickBeard's %s branch", fork)
else: elif fork in SICKBEARD_FAILED:
Logger.info("The download failed. Nothing to process") Logger.info("The download failed. Sending 'failed' process request to SickBeard's %s branch", fork)
if delete_failed and os.path.isdir(dirName) and not dirName in ['sys.argv[0]','/','']: else:
delete(dirName) Logger.info("The download failed. SickBeard's %s branch does not handle failed downloads. Nothing to process", fork)
return 0 # Success (as far as this script is concerned) 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 if status == 0 and transcode == 1: # only transcode successful downlaods
result = Transcoder.Transcode_directory(dirName) result = Transcoder.Transcode_directory(dirName)

View file

@ -6,3 +6,12 @@ VERSION = 'V8.6'
# Constants pertinant to SabNzb # Constants pertinant to SabNzb
SABNZB_NO_OF_ARGUMENTS = 8 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"]