2012-10-30 10:43:01 +00:00
|
|
|
import sys
|
|
|
|
import urllib
|
|
|
|
import os.path
|
|
|
|
import ConfigParser
|
|
|
|
|
|
|
|
class AuthURLOpener(urllib.FancyURLopener):
|
|
|
|
def __init__(self, user, pw):
|
|
|
|
self.username = user
|
|
|
|
self.password = pw
|
|
|
|
self.numTries = 0
|
|
|
|
urllib.FancyURLopener.__init__(self)
|
|
|
|
|
|
|
|
def prompt_user_passwd(self, host, realm):
|
|
|
|
if self.numTries == 0:
|
|
|
|
self.numTries = 1
|
|
|
|
return (self.username, self.password)
|
|
|
|
else:
|
|
|
|
return ('', '')
|
|
|
|
|
|
|
|
def openit(self, url):
|
|
|
|
self.numTries = 0
|
|
|
|
return urllib.FancyURLopener.open(self, url)
|
|
|
|
|
|
|
|
|
FIX: (#746) updated autoProcessComics.py / ComicRN.py's which will now send proper completion messeages to clients, FIX: (#752) refresh series will now test if a series is 'out of whack' with it's numerical issue count (ie. 5/4) or it has no issue data due to a bad refresh / api maxing out and will adjust it's processing to accomodate either, IMP: (#750) Added ComicVine API Checker which will check API counts at regular intervals to inform/warn users of usage, as well as adding a screen-time display of API hits / mins used at the bottom of every page (refreshing/reloading pages will update counts), FIX: (#747)EOL normalization (dos2unix) on search.py - removed classes & exceptions as not being used, IMP: (#747) Skip processing issues with an invalid store date & issue date (thnx rupaschomaker), FIX: Removed strings when searching/logging torrents as was causing ascii errors especially with KAT, IMP: Added [META-TAGGING] to logging for meta-tagging module, IMP: Added ability in GUI to select CR or Cbl tags (or both) when writing metadata to cbz files, IMP: Improved support/usage with ComicTagger v1.1.15 which allows for personal CV API Key usage - if supplied to Mylar, will use when tagging with ComicTagger, IMP: Added Manual Search option to allow for individual searches of issues without changing initial status.
2014-06-18 19:58:19 +00:00
|
|
|
def processIssue(dirName, nzbName=None):
|
2012-10-30 10:43:01 +00:00
|
|
|
|
|
|
|
config = ConfigParser.ConfigParser()
|
|
|
|
configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessComics.cfg")
|
|
|
|
print "Loading config from", configFilename
|
|
|
|
|
|
|
|
if not os.path.isfile(configFilename):
|
|
|
|
print "ERROR: You need an autoProcessComics.cfg file - did you rename and edit the .sample?"
|
|
|
|
sys.exit(-1)
|
|
|
|
|
|
|
|
try:
|
|
|
|
fp = open(configFilename, "r")
|
|
|
|
config.readfp(fp)
|
|
|
|
fp.close()
|
|
|
|
except IOError, e:
|
|
|
|
print "Could not read configuration file: ", str(e)
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
host = config.get("Mylar", "host")
|
|
|
|
port = config.get("Mylar", "port")
|
|
|
|
username = config.get("Mylar", "username")
|
|
|
|
password = config.get("Mylar", "password")
|
|
|
|
try:
|
|
|
|
ssl = int(config.get("Mylar", "ssl"))
|
|
|
|
except (ConfigParser.NoOptionError, ValueError):
|
|
|
|
ssl = 0
|
|
|
|
|
|
|
|
try:
|
|
|
|
web_root = config.get("Mylar", "web_root")
|
|
|
|
except ConfigParser.NoOptionError:
|
|
|
|
web_root = ""
|
|
|
|
|
|
|
|
params = {}
|
|
|
|
|
|
|
|
params['nzb_folder'] = dirName
|
|
|
|
if nzbName != None:
|
|
|
|
params['nzb_name'] = nzbName
|
|
|
|
|
|
|
|
myOpener = AuthURLOpener(username, password)
|
|
|
|
|
|
|
|
if ssl:
|
|
|
|
protocol = "https://"
|
|
|
|
else:
|
|
|
|
protocol = "http://"
|
|
|
|
|
|
|
|
url = protocol + host + ":" + port + web_root + "/post_process?" + urllib.urlencode(params)
|
|
|
|
|
|
|
|
print "Opening URL:", url
|
|
|
|
|
|
|
|
try:
|
|
|
|
urlObj = myOpener.openit(url)
|
|
|
|
except IOError, e:
|
|
|
|
print "Unable to open URL: ", str(e)
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
result = urlObj.readlines()
|
|
|
|
for line in result:
|
|
|
|
print line
|
2013-05-16 17:46:34 +00:00
|
|
|
|
FIX: (#746) updated autoProcessComics.py / ComicRN.py's which will now send proper completion messeages to clients, FIX: (#752) refresh series will now test if a series is 'out of whack' with it's numerical issue count (ie. 5/4) or it has no issue data due to a bad refresh / api maxing out and will adjust it's processing to accomodate either, IMP: (#750) Added ComicVine API Checker which will check API counts at regular intervals to inform/warn users of usage, as well as adding a screen-time display of API hits / mins used at the bottom of every page (refreshing/reloading pages will update counts), FIX: (#747)EOL normalization (dos2unix) on search.py - removed classes & exceptions as not being used, IMP: (#747) Skip processing issues with an invalid store date & issue date (thnx rupaschomaker), FIX: Removed strings when searching/logging torrents as was causing ascii errors especially with KAT, IMP: Added [META-TAGGING] to logging for meta-tagging module, IMP: Added ability in GUI to select CR or Cbl tags (or both) when writing metadata to cbz files, IMP: Improved support/usage with ComicTagger v1.1.15 which allows for personal CV API Key usage - if supplied to Mylar, will use when tagging with ComicTagger, IMP: Added Manual Search option to allow for individual searches of issues without changing initial status.
2014-06-18 19:58:19 +00:00
|
|
|
if any("Post Processing SUCCESSFUL" in s for s in result):
|
2013-05-16 17:46:34 +00:00
|
|
|
return 0
|
2013-05-17 01:36:10 +00:00
|
|
|
else:
|
2013-05-16 17:46:34 +00:00
|
|
|
return 1
|