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
|
option, value = item
|
||||||
confignew.set(section, option, value)
|
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"
|
section = "loggers"
|
||||||
original = []
|
original = []
|
||||||
try:
|
try:
|
||||||
|
@ -246,9 +256,10 @@ def migrate():
|
||||||
os.unlink(backupname)
|
os.unlink(backupname)
|
||||||
os.rename(configFilenameold, backupname)
|
os.rename(configFilenameold, backupname)
|
||||||
|
|
||||||
# rename our newly edited autoProcessMedia.cfg.sample to autoProcessMedia.cfg
|
if os.path.isfile(configFilenamenew):
|
||||||
os.rename(configFilenamenew, configFilenameold)
|
# rename our newly edited autoProcessMedia.cfg.sample to autoProcessMedia.cfg
|
||||||
return
|
os.rename(configFilenamenew, configFilenameold)
|
||||||
|
return
|
||||||
|
|
||||||
def addnzbget():
|
def addnzbget():
|
||||||
confignew = ConfigParser.ConfigParser()
|
confignew = ConfigParser.ConfigParser()
|
||||||
|
|
|
@ -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).
|
#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
|
convert = 0
|
||||||
|
|
||||||
|
[passwords]
|
||||||
|
#Set a list of passwords to be used for extraction attempts. e.g
|
||||||
|
#password1 = password
|
||||||
|
#password2 = secret
|
||||||
|
|
||||||
# Logging configuration
|
# Logging configuration
|
||||||
[loggers]
|
[loggers]
|
||||||
keys = root
|
keys = root
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import ConfigParser
|
||||||
sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]),'autoProcess/'))
|
sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]),'autoProcess/'))
|
||||||
import logging
|
import logging
|
||||||
from subprocess import call, Popen, PIPE
|
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.
|
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)
|
Logger.info("EXTRACTOR: Extraction was successful for %s to %s", filePath, outputDestination)
|
||||||
else:
|
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:
|
except:
|
||||||
Logger.exception("EXTRACTOR: Extraction failed for %s. Could not call command %s", filePath, cmd)
|
Logger.exception("EXTRACTOR: Extraction failed for %s. Could not call command %s", filePath, cmd)
|
||||||
os.chdir(pwd) # Go back to our Original Working Directory
|
os.chdir(pwd) # Go back to our Original Working Directory
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue