mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-20 21:33:13 -07:00
change passwords to read from external list. fixes #211
This commit is contained in:
parent
a8006d8034
commit
86abf0f78c
2 changed files with 19 additions and 12 deletions
|
@ -154,9 +154,9 @@ delay = 120
|
||||||
convert = 0
|
convert = 0
|
||||||
|
|
||||||
[passwords]
|
[passwords]
|
||||||
#Set a list of passwords to be used for extraction attempts. e.g
|
# enter the full path to a text file containing passwords to be used for extraction attempts.
|
||||||
#password1 = password
|
# In the passwords file, every password should be on a new line
|
||||||
#password2 = secret
|
PassWordFile =
|
||||||
|
|
||||||
# Logging configuration
|
# Logging configuration
|
||||||
[loggers]
|
[loggers]
|
||||||
|
|
|
@ -112,6 +112,16 @@ def extract(filePath, outputDestination):
|
||||||
# Create outputDestination folder
|
# Create outputDestination folder
|
||||||
create_destination(outputDestination)
|
create_destination(outputDestination)
|
||||||
|
|
||||||
|
config = ConfigParser.ConfigParser()
|
||||||
|
configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
||||||
|
Logger.info("MAIN: Loading config from %s", configFilename)
|
||||||
|
config.read(configFilename)
|
||||||
|
passwordsfile = config.get("passwords", "PassWordFile")
|
||||||
|
if passwordsfile != "" and os.path.isfile(os.path.normpath(passwordsfile)):
|
||||||
|
passwords = [line.strip() for line in open(os.path.normpath(passwordsfile))]
|
||||||
|
else:
|
||||||
|
passwords = []
|
||||||
|
|
||||||
Logger.info("Extracting %s to %s", filePath, outputDestination)
|
Logger.info("Extracting %s to %s", filePath, outputDestination)
|
||||||
Logger.debug("Extracting %s %s %s", cmd, filePath, outputDestination)
|
Logger.debug("Extracting %s %s %s", cmd, filePath, outputDestination)
|
||||||
pwd = os.getcwd() # Get our Present Working Directory
|
pwd = os.getcwd() # Get our Present Working Directory
|
||||||
|
@ -124,23 +134,20 @@ def extract(filePath, outputDestination):
|
||||||
res = p.wait()
|
res = p.wait()
|
||||||
if (res >= 0 and os.name == 'nt') or res == 0: # for windows chp returns process id if successful or -1*Error code. Linux returns 0 for successful.
|
if (res >= 0 and os.name == 'nt') or 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)
|
Logger.info("EXTRACTOR: Extraction was successful for %s to %s", filePath, outputDestination)
|
||||||
else:
|
elif len(passwords) > 0:
|
||||||
Logger.info("EXTRACTOR: Attempting to extract with passwords")
|
Logger.info("EXTRACTOR: Attempting to extract with passwords")
|
||||||
pass_success = int(0)
|
pass_success = int(0)
|
||||||
passwords = ConfigParser.ConfigParser()
|
for password in passwords:
|
||||||
passwordsfile = os.path.join(os.path.dirname(sys.argv[0]), 'autoProcessMedia.cfg')
|
if password == "": # if edited in windows or otherwise if blank lines.
|
||||||
passwords.read(passwordsfile)
|
continue
|
||||||
passwordslist = passwords.items('passwords')
|
|
||||||
for item in passwordslist:
|
|
||||||
option, password = item
|
|
||||||
cmd2 = cmd
|
cmd2 = cmd
|
||||||
#append password here.
|
#append password here.
|
||||||
passcmd = "-p" + password
|
passcmd = "-p" + password
|
||||||
cmd2.append(passcmd)
|
cmd2.append(passcmd)
|
||||||
p = Popen(cmd2) # should extract files fine.
|
p = Popen(cmd2) # should extract files fine.
|
||||||
res = p.wait()
|
res = p.wait()
|
||||||
if res >= 0: # for windows chp returns process id if successful or -1*Error code. Linux returns 0 for successful.
|
if (res >= 0 and os.name == 'nt') or 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)
|
Logger.info("EXTRACTOR: Extraction was successful for %s to %s using password: %s", filePath, outputDestination, password)
|
||||||
pass_success = int(1)
|
pass_success = int(1)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue