mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-04-19 10:21:19 +02:00
code style
This commit is contained in:
parent
7eeed17ea5
commit
1b49911166
@ -48,7 +48,8 @@ def cmd_parser():
|
||||
|
||||
# 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.')
|
||||
@ -58,8 +59,8 @@ def cmd_parser():
|
||||
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='',
|
||||
|
@ -40,13 +40,13 @@ def main():
|
||||
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)
|
||||
|
@ -169,7 +169,7 @@ def doujinshi_parser(id_):
|
||||
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
|
||||
@ -194,7 +194,7 @@ def print_doujinshi(doujinshi_list):
|
||||
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(' ', '-')
|
||||
|
Loading…
x
Reference in New Issue
Block a user