mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-04-20 02:41:19 +02:00
max page #26
This commit is contained in:
parent
963f4d9ddf
commit
b8ea917db2
@ -47,6 +47,8 @@ def cmd_parser():
|
||||
parser.add_option('--page', type='int', dest='page', action='store', default=1,
|
||||
help='page number of search result')
|
||||
parser.add_option('--tag', type='string', dest='tag', action='store', help='download doujinshi by tag')
|
||||
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('--output', type='string', dest='output_dir', action='store', default='',
|
||||
help='output dir')
|
||||
parser.add_option('--threads', '-t', type='int', dest='threads', action='store', default=5,
|
||||
|
@ -30,7 +30,7 @@ def main():
|
||||
if options.tag:
|
||||
tag_id = tag_guessing(options.tag)
|
||||
if tag_id:
|
||||
doujinshis = tag_parser(tag_id)
|
||||
doujinshis = tag_parser(tag_id, max_page=options.max_page)
|
||||
print_doujinshi(doujinshis)
|
||||
if options.is_download:
|
||||
doujinshi_ids = map(lambda d: d['id'], doujinshis)
|
||||
|
@ -161,10 +161,17 @@ def print_doujinshi(doujinshi_list):
|
||||
logger.info('Search Result\n{}'.format(data))
|
||||
|
||||
|
||||
def tag_parser(tag_id):
|
||||
def tag_parser(tag_id, max_page=1):
|
||||
logger.info('Get doujinshi of tag id: {0}'.format(tag_id))
|
||||
result = []
|
||||
response = request('get', url=constant.TAG_API_URL, params={'sort': 'popular', 'tag_id': tag_id}).json()
|
||||
page = max_page if max_page <= response['num_pages'] else int(response['num_pages'])
|
||||
|
||||
for i in range(1, page+1):
|
||||
logger.info('Get page {} ...'.format(i))
|
||||
|
||||
if page != 1:
|
||||
response = request('get', url=constant.TAG_API_URL, params={'sort': 'popular', 'tag_id': tag_id}).json()
|
||||
|
||||
for row in response['result']:
|
||||
title = row['title']['english']
|
||||
|
Loading…
x
Reference in New Issue
Block a user