Fix error when multiple comics match

This commit is contained in:
Bastian Kleineidam 2013-03-11 19:44:42 +01:00
parent 7ee73caf3c
commit 2b0d2d3a70
2 changed files with 11 additions and 3 deletions

View file

@ -14,6 +14,8 @@ Fixes:
- cmdline: Catch error when piping output to another - cmdline: Catch error when piping output to another
program or file under Windows. program or file under Windows.
Closes: GH bug #13 Closes: GH bug #13
- cmdline: Catch error when multiple comics match.
Closes: GH bug #16
- comics: Retry download on empty content to reduce empty file errors. - comics: Retry download on empty content to reduce empty file errors.

12
dosage
View file

@ -158,7 +158,6 @@ def getComics(options):
for scraperobj in getScrapers(options.comic, options.basepath, options.adult, options.multimatch): for scraperobj in getScrapers(options.comic, options.basepath, options.adult, options.multimatch):
errors += getStrips(scraperobj, options) errors += getStrips(scraperobj, options)
finally: finally:
out.context = ''
events.getHandler().end() events.getHandler().end()
return errors return errors
@ -166,7 +165,6 @@ def getComics(options):
def getStrips(scraperobj, options): def getStrips(scraperobj, options):
"""Get all strips from a scraper.""" """Get all strips from a scraper."""
errors = 0 errors = 0
out.context = scraperobj.getName()
if options.all: if options.all:
numstrips = None numstrips = None
elif options.numstrips: elif options.numstrips:
@ -175,6 +173,7 @@ def getStrips(scraperobj, options):
# get current strip # get current strip
numstrips = 1 numstrips = 1
try: try:
out.context = scraperobj.getName()
for strip in scraperobj.getStrips(numstrips): for strip in scraperobj.getStrips(numstrips):
_errors, skipped = saveComicStrip(strip, options.basepath) _errors, skipped = saveComicStrip(strip, options.basepath)
errors += _errors errors += _errors
@ -185,6 +184,8 @@ def getStrips(scraperobj, options):
except Exception as msg: except Exception as msg:
out.error(msg) out.error(msg)
errors += 1 errors += 1
finally:
out.context = ''
return errors return errors
@ -292,7 +293,12 @@ def getScrapers(comics, basepath=None, adult=True, multiple_allowed=False):
else: else:
name = comic name = comic
indexes = None indexes = None
for scraperclass in scraper.find_scraperclasses(name, multiple_allowed=multiple_allowed): try:
scraperclasses = scraper.find_scraperclasses(name, multiple_allowed=multiple_allowed)
except ValueError as msg:
out.error(msg)
continue
for scraperclass in scraperclasses:
if not adult and scraperclass.adult: if not adult and scraperclass.adult:
warn_adult(scraperclass) warn_adult(scraperclass)
continue continue