mirror of
				https://github.com/RicterZ/nhentai.git
				synced 2025-11-04 11:00:55 +01:00 
			
		
		
		
	code style
This commit is contained in:
		@@ -48,7 +48,8 @@ def cmd_parser():
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    # doujinshi options
 | 
					    # doujinshi options
 | 
				
			||||||
    parser.add_option('--id', type='string', dest='id', action='store', help='doujinshi ids set, e.g. 1,2,3')
 | 
					    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('--tag', type='string', dest='tag', action='store', help='download doujinshi by tag')
 | 
				
			||||||
    parser.add_option('--favorites', '-F', action='store_true', dest='favorites',
 | 
					    parser.add_option('--favorites', '-F', action='store_true', dest='favorites',
 | 
				
			||||||
                      help='list or download your favorites.')
 | 
					                      help='list or download your favorites.')
 | 
				
			||||||
@@ -58,8 +59,8 @@ def cmd_parser():
 | 
				
			|||||||
                      help='page number of search results')
 | 
					                      help='page number of search results')
 | 
				
			||||||
    parser.add_option('--max-page', type='int', dest='max_page', action='store', default=1,
 | 
					    parser.add_option('--max-page', type='int', dest='max_page', action='store', default=1,
 | 
				
			||||||
                      help='The max page when recursive download tagged doujinshi')
 | 
					                      help='The max page when recursive download tagged doujinshi')
 | 
				
			||||||
    parser.add_option('--sorting', type='string', dest='sorting', action='store', default='date',
 | 
					    parser.add_option('--sorting', dest='sorting', action='store', default='date',
 | 
				
			||||||
                      help='sorting of doujinshi, e.g. date/popular')
 | 
					                      help='sorting of doujinshi (date / popular)', choices=['date', 'popular'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # 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='',
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -40,13 +40,13 @@ def main():
 | 
				
			|||||||
            doujinshi_ids = map(lambda d: d['id'], doujinshis)
 | 
					            doujinshi_ids = map(lambda d: d['id'], doujinshis)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    elif options.tag:
 | 
					    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)
 | 
					        print_doujinshi(doujinshis)
 | 
				
			||||||
        if options.is_download and doujinshis:
 | 
					        if options.is_download and doujinshis:
 | 
				
			||||||
            doujinshi_ids = map(lambda d: d['id'], doujinshis)
 | 
					            doujinshi_ids = map(lambda d: d['id'], doujinshis)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    elif options.keyword:
 | 
					    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)
 | 
					        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)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -169,7 +169,7 @@ def doujinshi_parser(id_):
 | 
				
			|||||||
    return doujinshi
 | 
					    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))
 | 
					    logger.debug('Searching doujinshis of keyword {0}'.format(keyword))
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        response = request('get', url=constant.SEARCH_URL, params={'q': keyword, 'page': page, 'sort': sorting}).content
 | 
					        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'))
 | 
					                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 = []
 | 
					    result = []
 | 
				
			||||||
    tag_name = tag_name.lower()
 | 
					    tag_name = tag_name.lower()
 | 
				
			||||||
    tag_name = tag_name.replace(' ', '-')
 | 
					    tag_name = tag_name.replace(' ', '-')
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user