mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-04-20 11:01:17 +02:00
change sorting from recent to date
This commit is contained in:
parent
e5ed6d098a
commit
501840172e
@ -71,9 +71,9 @@ def cmd_parser():
|
|||||||
help='all search results')
|
help='all search results')
|
||||||
parser.add_option('--page', '--page-range', type='string', dest='page', action='store', default='',
|
parser.add_option('--page', '--page-range', type='string', dest='page', action='store', default='',
|
||||||
help='page number of search results. e.g. 1,2-5,14')
|
help='page number of search results. e.g. 1,2-5,14')
|
||||||
parser.add_option('--sorting', dest='sorting', action='store', default='recent',
|
parser.add_option('--sorting', dest='sorting', action='store', default='date',
|
||||||
help='sorting of doujinshi (recent / popular / popular-[today|week])',
|
help='sorting of doujinshi (recent / popular / popular-[today|week])',
|
||||||
choices=['recent', 'popular', 'popular-today', 'popular-week'])
|
choices=['recent', 'popular', 'popular-today', 'popular-week', 'date'])
|
||||||
|
|
||||||
# download options
|
# download options
|
||||||
parser.add_option('--output', '-o', type='string', dest='output_dir', action='store', default='./',
|
parser.add_option('--output', '-o', type='string', dest='output_dir', action='store', default='./',
|
||||||
@ -112,7 +112,7 @@ def cmd_parser():
|
|||||||
# nhentai options
|
# nhentai options
|
||||||
parser.add_option('--cookie', type='str', dest='cookie', action='store',
|
parser.add_option('--cookie', type='str', dest='cookie', action='store',
|
||||||
help='set cookie of nhentai to bypass Cloudflare captcha')
|
help='set cookie of nhentai to bypass Cloudflare captcha')
|
||||||
parser.add_option('--useragent', type='str', dest='useragent', action='store',
|
parser.add_option('--useragent', '--user-agent', type='str', dest='useragent', action='store',
|
||||||
help='set useragent to bypass Cloudflare captcha')
|
help='set useragent to bypass Cloudflare captcha')
|
||||||
parser.add_option('--language', type='str', dest='language', action='store',
|
parser.add_option('--language', type='str', dest='language', action='store',
|
||||||
help='set default language to parse doujinshis')
|
help='set default language to parse doujinshis')
|
||||||
@ -158,7 +158,7 @@ def cmd_parser():
|
|||||||
elif args.useragent is not None:
|
elif args.useragent is not None:
|
||||||
constant.CONFIG['useragent'] = args.useragent
|
constant.CONFIG['useragent'] = args.useragent
|
||||||
write_config()
|
write_config()
|
||||||
logger.info('Useragent saved.')
|
logger.info('User-Agent saved.')
|
||||||
exit(0)
|
exit(0)
|
||||||
elif args.language is not None:
|
elif args.language is not None:
|
||||||
constant.CONFIG['language'] = args.language
|
constant.CONFIG['language'] = args.language
|
||||||
|
@ -200,6 +200,7 @@ def print_doujinshi(doujinshi_list):
|
|||||||
def search_parser(keyword, sorting, page, is_page_all=False):
|
def search_parser(keyword, sorting, page, is_page_all=False):
|
||||||
# keyword = '+'.join([i.strip().replace(' ', '-').lower() for i in keyword.split(',')])
|
# keyword = '+'.join([i.strip().replace(' ', '-').lower() for i in keyword.split(',')])
|
||||||
result = []
|
result = []
|
||||||
|
response = None
|
||||||
if not page:
|
if not page:
|
||||||
page = [1]
|
page = [1]
|
||||||
|
|
||||||
@ -217,13 +218,14 @@ def search_parser(keyword, sorting, page, is_page_all=False):
|
|||||||
try:
|
try:
|
||||||
url = request('get', url=constant.SEARCH_URL, params={'query': keyword,
|
url = request('get', url=constant.SEARCH_URL, params={'query': keyword,
|
||||||
'page': p, 'sort': sorting}).url
|
'page': p, 'sort': sorting}).url
|
||||||
|
print(url)
|
||||||
response = request('get', url.replace('%2B', '+')).json()
|
response = request('get', url.replace('%2B', '+')).json()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.critical(str(e))
|
logger.critical(str(e))
|
||||||
|
response = None
|
||||||
break
|
break
|
||||||
|
|
||||||
if 'result' not in response:
|
if response is None or 'result' not in response:
|
||||||
logger.warning('No result in response in page {}'.format(p))
|
logger.warning('No result in response in page {}'.format(p))
|
||||||
break
|
break
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user