]> git.lizzy.rs Git - nhentai.git/blobdiff - nhentai/cmdline.py
support multi viewers
[nhentai.git] / nhentai / cmdline.py
index 2d59309f50ffa7fefcc9e11c327a4429d1cca27e..59dadac91c1167dba4f12d4a34c04c123b329a7d 100644 (file)
@@ -126,6 +126,8 @@ def cmd_parser():
                       default=False, help='save downloaded doujinshis, whose will be skipped if you re-download them')
     parser.add_option('--clean-download-history', action='store_true', default=False, dest='clean_download_history',
                       help='clean download history')
+    parser.add_option('--template', dest='viewer_template', action='store',
+                      help='set viewer template', default='')
 
     try:
         sys.argv = [unicode(i.decode(sys.stdin.encoding)) for i in sys.argv]
@@ -179,6 +181,19 @@ def cmd_parser():
             logger.info('Proxy now set to \'{0}\'.'.format(args.proxy))
             write_config()
             exit(0)
+
+    if args.viewer_template:
+        if not args.viewer_template:
+            args.viewer_template = 'default'
+
+        if not os.path.exists(os.path.join(os.path.dirname(__file__),
+                                           'viewer/{}/index.html'.format(args.viewer_template))):
+            logger.error('Template \'{}\' does not exists'.format(args.viewer_template))
+            exit(1)
+        else:
+            constant.CONFIG['template'] = args.viewer_template
+            write_config()
+
     # --- end set config ---
 
     if args.favorites: