adding no downsize option
This commit is contained in:
parent
77a9cce00d
commit
4529fdee3b
3 changed files with 12 additions and 6 deletions
1
dosage
1
dosage
|
@ -75,6 +75,7 @@ def setupOptions():
|
|||
parser.add_argument('-m', '--modulehelp', action='store_true', help='display help for comic modules')
|
||||
parser.add_argument('-t', '--timestamps', action='store_true', help='print timestamps for all output at any info level')
|
||||
parser.add_argument('-o', '--output', action='append', dest='handler', choices=events.getHandlerNames(), help='sets output handlers for downloaded comics')
|
||||
parser.add_argument('--no-downscale', action='store_false', dest='allowdownscale', help='prevent downscaling when using html or rss handler')
|
||||
parser.add_argument('-p', '--parallel', action='store', type=int, default=1, help='fetch comics in parallel. Specify the number of connections')
|
||||
parser.add_argument('--adult', action='store_true', help='confirms that you are old enough to view adult content')
|
||||
# used for development testing prev/next matching
|
||||
|
|
|
@ -154,7 +154,7 @@ def getComics(options):
|
|||
"""Retrieve comics."""
|
||||
if options.handler:
|
||||
for name in set(options.handler):
|
||||
events.addHandler(name, options.basepath, options.baseurl)
|
||||
events.addHandler(name, options.basepath, options.baseurl, options.allowdownscale)
|
||||
events.getHandler().start()
|
||||
errors = 0
|
||||
try:
|
||||
|
|
|
@ -20,10 +20,11 @@ class EventHandler(object):
|
|||
"""Base class for writing events to files. The currently defined events are
|
||||
start(), comicDownloaded() and end()."""
|
||||
|
||||
def __init__(self, basepath, baseurl):
|
||||
def __init__(self, basepath, baseurl, allowdownscale):
|
||||
"""Initialize base path and url."""
|
||||
self.basepath = basepath
|
||||
self.baseurl = baseurl or self.getBaseUrl()
|
||||
self.allowdownscale = allowdownscale
|
||||
|
||||
def getBaseUrl(self):
|
||||
'''Return a file: URL that probably points to the basedir.
|
||||
|
@ -87,7 +88,9 @@ class RSSEventHandler(EventHandler):
|
|||
def comicDownloaded(self, comic, filename, text=None):
|
||||
"""Write RSS entry for downloaded comic."""
|
||||
imageUrl = self.getUrlFromFilename(filename)
|
||||
size = getDimensionForImage(filename, MaxImageSize)
|
||||
size = None
|
||||
if self.allowdownscale:
|
||||
size = getDimensionForImage(filename, MaxImageSize)
|
||||
title = '%s - %s' % (comic.name, os.path.basename(filename))
|
||||
pageUrl = comic.referrer
|
||||
description = '<img src="%s"' % imageUrl
|
||||
|
@ -198,7 +201,9 @@ class HtmlEventHandler(EventHandler):
|
|||
"""Write HTML entry for downloaded comic."""
|
||||
if self.lastComic != comic.name:
|
||||
self.newComic(comic)
|
||||
size = getDimensionForImage(filename, MaxImageSize)
|
||||
size = None
|
||||
if self.allowdownscale:
|
||||
size = getDimensionForImage(filename, MaxImageSize)
|
||||
imageUrl = self.getUrlFromFilename(filename)
|
||||
pageUrl = comic.referrer
|
||||
if pageUrl != self.lastUrl:
|
||||
|
@ -302,11 +307,11 @@ def getHandlerNames():
|
|||
|
||||
_handlers = []
|
||||
|
||||
def addHandler(name, basepath=None, baseurl=None):
|
||||
def addHandler(name, basepath=None, baseurl=None, allowDownscale=False):
|
||||
"""Add an event handler with given name."""
|
||||
if basepath is None:
|
||||
basepath = '.'
|
||||
_handlers.append(_handler_classes[name](basepath, baseurl))
|
||||
_handlers.append(_handler_classes[name](basepath, baseurl, allowDownscale))
|
||||
|
||||
|
||||
class MultiHandler(object):
|
||||
|
|
Loading…
Reference in a new issue