mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-07-16 02:02:53 -07:00
add passwords for extraction. fix #211
This commit is contained in:
parent
864a5a79be
commit
39f49cf757
3 changed files with 42 additions and 4 deletions
|
@ -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,6 +256,7 @@ def migrate():
|
|||
os.unlink(backupname)
|
||||
os.rename(configFilenameold, backupname)
|
||||
|
||||
if os.path.isfile(configFilenamenew):
|
||||
# rename our newly edited autoProcessMedia.cfg.sample to autoProcessMedia.cfg
|
||||
os.rename(configFilenamenew, configFilenameold)
|
||||
return
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,6 +123,27 @@ 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.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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue