diff --git a/autoProcess/migratecfg.py b/autoProcess/migratecfg.py index 8bacc4d3..02c18912 100644 --- a/autoProcess/migratecfg.py +++ b/autoProcess/migratecfg.py @@ -175,6 +175,16 @@ def migrate(): option, value = item confignew.set(section, option, value) + section = "passwords" + original = [] + try: + original = configold.items(section) + except: + pass + for item in original: + option, value = item + confignew.set(section, option, value) + section = "loggers" original = [] try: @@ -246,9 +256,10 @@ def migrate(): os.unlink(backupname) os.rename(configFilenameold, backupname) - # rename our newly edited autoProcessMedia.cfg.sample to autoProcessMedia.cfg - os.rename(configFilenamenew, configFilenameold) - return + if os.path.isfile(configFilenamenew): + # rename our newly edited autoProcessMedia.cfg.sample to autoProcessMedia.cfg + os.rename(configFilenamenew, configFilenameold) + return def addnzbget(): confignew = ConfigParser.ConfigParser() diff --git a/autoProcessMedia.cfg.sample b/autoProcessMedia.cfg.sample index 735a45bd..ae596deb 100644 --- a/autoProcessMedia.cfg.sample +++ b/autoProcessMedia.cfg.sample @@ -149,6 +149,11 @@ delay = 120 #Set convert =1 if you want to convert any "foreign" characters to ASCII before passing to SB/CP etc. Default is disabled (0). convert = 0 +[passwords] +#Set a list of passwords to be used for extraction attempts. e.g +#password1 = password +#password2 = secret + # Logging configuration [loggers] keys = root diff --git a/extractor/extractor.py b/extractor/extractor.py index 8044684a..de312d20 100644 --- a/extractor/extractor.py +++ b/extractor/extractor.py @@ -1,5 +1,6 @@ import os import sys +import ConfigParser sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]),'autoProcess/')) import logging from subprocess import call, Popen, PIPE @@ -122,7 +123,28 @@ def extract(filePath, outputDestination): if res >= 0: # for windows chp returns process id if successful or -1*Error code. Linux returns 0 for successful. Logger.info("EXTRACTOR: Extraction was successful for %s to %s", filePath, outputDestination) else: - Logger.error("EXTRACTOR: Extraction failed for %s. 7zip result was %s", filePath, res) + Logger.info("EXTRACTOR: Attempting to extract with passwords") + pass_success = int(0) + passwords = ConfigParser.ConfigParser() + passwordsfile = os.path.join(os.path.dirname(sys.argv[0]), 'autoProcessMedia.cfg') + passwords.read(passwordsfile) + passwordslist = passwords.items('passwords') + for item in passwordslist: + option, password = item + cmd2 = cmd + #append password here. + passcmd = "-p" + password + cmd2.append(passcmd) + p = Popen(cmd2) # should extract files fine. + res = p.wait() + if res >= 0: # for windows chp returns process id if successful or -1*Error code. Linux returns 0 for successful. + Logger.info("EXTRACTOR: Extraction was successful for %s to %s", filePath, outputDestination) + pass_success = int(1) + break + else: + continue + if pass_success == int(0): + Logger.error("EXTRACTOR: Extraction failed for %s. 7zip result was %s", filePath, res) except: Logger.exception("EXTRACTOR: Extraction failed for %s. Could not call command %s", filePath, cmd) os.chdir(pwd) # Go back to our Original Working Directory