Add adult option.
This commit is contained in:
parent
faba7b0bca
commit
9130f90ef7
1 changed files with 14 additions and 4 deletions
18
dosage
18
dosage
|
@ -45,6 +45,7 @@ def setupOptions():
|
||||||
parser.add_option('-m', '--modulehelp', action='store_true', dest='modhelp', help='display help for comic modules')
|
parser.add_option('-m', '--modulehelp', action='store_true', dest='modhelp', help='display help for comic modules')
|
||||||
parser.add_option('-t', '--timestamps', action='store_true', dest='timestamps', default=False, help='print timestamps for all output at any info level')
|
parser.add_option('-t', '--timestamps', action='store_true', dest='timestamps', default=False, help='print timestamps for all output at any info level')
|
||||||
parser.add_option('-o', '--output', action='store', dest='output', choices=events.getHandlers(), help='output formatting for downloaded comics')
|
parser.add_option('-o', '--output', action='store', dest='output', choices=events.getHandlers(), help='output formatting for downloaded comics')
|
||||||
|
parser.add_option('--adult', action='store_true', dest='adult', default=False, help='confirms that you are old enough to view adult content')
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,12 +94,11 @@ def displayHelp(comics, basepath):
|
||||||
|
|
||||||
def getComics(options, comics):
|
def getComics(options, comics):
|
||||||
"""Retrieve given comics."""
|
"""Retrieve given comics."""
|
||||||
# XXX refactor
|
|
||||||
errors = 0
|
errors = 0
|
||||||
if options.output:
|
if options.output:
|
||||||
events.installHandler(options.output, options.basepath, options.baseurl)
|
events.installHandler(options.output, options.basepath, options.baseurl)
|
||||||
events.getHandler().start()
|
events.getHandler().start()
|
||||||
for scraperobj in getScrapers(comics, options.basepath):
|
for scraperobj in getScrapers(comics, options.basepath, options.adult):
|
||||||
out.context = scraperobj.get_name()
|
out.context = scraperobj.get_name()
|
||||||
if options.all:
|
if options.all:
|
||||||
strips = scraperobj.getAllStrips()
|
strips = scraperobj.getAllStrips()
|
||||||
|
@ -172,19 +172,25 @@ def doColumnList(scrapers):
|
||||||
return num
|
return num
|
||||||
|
|
||||||
|
|
||||||
def getScrapers(comics, basepath=None):
|
def getScrapers(comics, basepath=None, adult=True):
|
||||||
"""Get scraper objects for the given comics."""
|
"""Get scraper objects for the given comics."""
|
||||||
if '@' in comics:
|
if '@' in comics:
|
||||||
# only scrapers whose directory already exists
|
# only scrapers whose directory already exists
|
||||||
if len(comics) > 1:
|
if len(comics) > 1:
|
||||||
out.warn("using '@' as comic name ignores all other specified comics.")
|
out.warn("using '@' as comic name ignores all other specified comics.")
|
||||||
for scraperclass in scraper.get_scrapers():
|
for scraperclass in scraper.get_scrapers():
|
||||||
|
if not adult and scraperclass.adult:
|
||||||
|
out.warn("skipping adult comic %s" % scraperclass.get_name())
|
||||||
|
continue
|
||||||
dirname = getDirname(scraperclass.get_name())
|
dirname = getDirname(scraperclass.get_name())
|
||||||
if os.path.isdir(os.path.join(basepath, dirname)):
|
if os.path.isdir(os.path.join(basepath, dirname)):
|
||||||
yield scraperclass()
|
yield scraperclass()
|
||||||
elif '@@' in comics:
|
elif '@@' in comics:
|
||||||
# all scrapers
|
# all scrapers
|
||||||
for scraperclass in scraper.get_scrapers():
|
for scraperclass in scraper.get_scrapers():
|
||||||
|
if not adult and scraperclass.adult:
|
||||||
|
out.warn("skipping adult comic %s" % scraperclass.get_name())
|
||||||
|
continue
|
||||||
yield scraperclass()
|
yield scraperclass()
|
||||||
else:
|
else:
|
||||||
# get only selected comic scrapers
|
# get only selected comic scrapers
|
||||||
|
@ -197,7 +203,11 @@ def getScrapers(comics, basepath=None):
|
||||||
else:
|
else:
|
||||||
name = comic
|
name = comic
|
||||||
indexes = None
|
indexes = None
|
||||||
scrapers.append(scraper.get_scraper(name)(indexes=indexes))
|
scraperclass = scraper.get_scraper(name)
|
||||||
|
if not adult and scraperclass.adult:
|
||||||
|
out.warn("skipping adult comic %s" % scraperclass.get_name())
|
||||||
|
continue
|
||||||
|
scrapers.append(scraperclass(indexes=indexes))
|
||||||
for s in scrapers:
|
for s in scrapers:
|
||||||
yield s
|
yield s
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue