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