]> git.lizzy.rs Git - nhentai.git/commitdiff
code style
authorRicterZ <ricterzheng@gmail.com>
Tue, 30 Jul 2019 15:03:29 +0000 (23:03 +0800)
committerRicterZ <ricterzheng@gmail.com>
Tue, 30 Jul 2019 15:03:29 +0000 (23:03 +0800)
nhentai/cmdline.py
nhentai/command.py
nhentai/parser.py

index 475c662ff3f74b5f7588dd2e38d435f0254ddf24..f34e54ed4ec3c5345c8a33226525ae1ef1c3fdff 100644 (file)
@@ -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='',
index 9d3cb686224b57cea563544a65adf4c108dcbb8c..7d7fbf0cd237d33f041daa05effde64c82cf50b6 100644 (file)
@@ -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)
index b6a23e2cc3b01e9bf263e33295b2153eb3ba8234..33130ec71e2a30d10583f611f7ca4c9521c19c85 100644 (file)
@@ -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(' ', '-')