# doujinshi options
parser.add_option('--id', type='string', dest='id', action='store', help='doujinshi ids set, e.g. 1,2,3')
- parser.add_option('--search', '-s', type='string', dest='keyword', action='store', help='search doujinshi by keyword')
+ parser.add_option('--search', '-s', type='string', dest='keyword', action='store',
+ help='search doujinshi by keyword')
parser.add_option('--tag', type='string', dest='tag', action='store', help='download doujinshi by tag')
parser.add_option('--favorites', '-F', action='store_true', dest='favorites',
help='list or download your favorites.')
help='page number of search results')
parser.add_option('--max-page', type='int', dest='max_page', action='store', default=1,
help='The max page when recursive download tagged doujinshi')
- parser.add_option('--sorting', type='string', dest='sorting', action='store', default='date',
- help='sorting of doujinshi, e.g. date/popular')
+ parser.add_option('--sorting', dest='sorting', action='store', default='date',
+ help='sorting of doujinshi (date / popular)', choices=['date', 'popular'])
# download options
parser.add_option('--output', '-o', type='string', dest='output_dir', action='store', default='',
doujinshi_ids = map(lambda d: d['id'], doujinshis)
elif options.tag:
- doujinshis = tag_parser(options.tag, options.sorting, max_page=options.max_page)
+ doujinshis = tag_parser(options.tag, sorting=options.sorting, max_page=options.max_page)
print_doujinshi(doujinshis)
if options.is_download and doujinshis:
doujinshi_ids = map(lambda d: d['id'], doujinshis)
elif options.keyword:
- doujinshis = search_parser(options.keyword, options.sorting, options.page)
+ doujinshis = search_parser(options.keyword, sorting=options.sorting, page=options.page)
print_doujinshi(doujinshis)
if options.is_download:
doujinshi_ids = map(lambda d: d['id'], doujinshis)
return doujinshi
-def search_parser(keyword, sorting, page):
+def search_parser(keyword, sorting='date', page=1):
logger.debug('Searching doujinshis of keyword {0}'.format(keyword))
try:
response = request('get', url=constant.SEARCH_URL, params={'q': keyword, 'page': page, 'sort': sorting}).content
tabulate(tabular_data=doujinshi_list, headers=headers, tablefmt='rst'))
-def tag_parser(tag_name, sorting, max_page=1):
+def tag_parser(tag_name, sorting='date', max_page=1):
result = []
tag_name = tag_name.lower()
tag_name = tag_name.replace(' ', '-')