From 4529fdee3bccfe06bd2b397fe19c6bb8c6f6bde4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damjan=20Ko=C5=A1ir?= Date: Wed, 20 May 2015 22:38:29 +1200 Subject: [PATCH] adding no downsize option --- dosage | 1 + dosagelib/director.py | 2 +- dosagelib/events.py | 15 ++++++++++----- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/dosage b/dosage index a52f5596a..040a03633 100755 --- a/dosage +++ b/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 diff --git a/dosagelib/director.py b/dosagelib/director.py index a621c5e2d..3d003486d 100644 --- a/dosagelib/director.py +++ b/dosagelib/director.py @@ -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: diff --git a/dosagelib/events.py b/dosagelib/events.py index e36c41f8a..600943acd 100644 --- a/dosagelib/events.py +++ b/dosagelib/events.py @@ -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 = '