mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-04-19 18:31:24 +02:00
support multi viewers
This commit is contained in:
parent
9c7354be32
commit
51074ee948
@ -1,9 +1,4 @@
|
||||
include README.md
|
||||
include requirements.txt
|
||||
include nhentai/viewer/index.html
|
||||
include nhentai/viewer/styles.css
|
||||
include nhentai/viewer/scripts.js
|
||||
include nhentai/viewer/main.html
|
||||
include nhentai/viewer/main.css
|
||||
include nhentai/viewer/main.js
|
||||
include nhentai/viewer/logo.png
|
||||
include nhentai/viewer/*
|
||||
include nhentai/viewer/default/*
|
@ -1,3 +1,3 @@
|
||||
__version__ = '0.4.6'
|
||||
__version__ = '0.4.7'
|
||||
__author__ = 'RicterZ'
|
||||
__email__ = 'ricterzheng@gmail.com'
|
||||
|
@ -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:
|
||||
|
@ -13,7 +13,7 @@ from nhentai.parser import doujinshi_parser, search_parser, print_doujinshi, fav
|
||||
from nhentai.doujinshi import Doujinshi
|
||||
from nhentai.downloader import Downloader
|
||||
from nhentai.logger import logger
|
||||
from nhentai.constant import NHENTAI_CONFIG_FILE, BASE_URL
|
||||
from nhentai.constant import BASE_URL
|
||||
from nhentai.utils import generate_html, generate_cbz, generate_main_html, generate_pdf, \
|
||||
paging, check_cookie, signal_handler, DB
|
||||
|
||||
@ -24,8 +24,11 @@ def main():
|
||||
logger.info('Using mirror: {0}'.format(BASE_URL))
|
||||
|
||||
# CONFIG['proxy'] will be changed after cmd_parser()
|
||||
if constant.CONFIG['proxy']:
|
||||
logger.info('Using proxy: {0}'.format(constant.CONFIG['proxy']))
|
||||
if constant.CONFIG['proxy']['http']:
|
||||
logger.info('Using proxy: {0}'.format(constant.CONFIG['proxy']['http']))
|
||||
|
||||
if constant.CONFIG['template']:
|
||||
logger.info('Using viewer template "{}"'.format(constant.CONFIG['template']))
|
||||
|
||||
# check your cookie
|
||||
check_cookie()
|
||||
@ -88,7 +91,7 @@ def main():
|
||||
db.add_one(doujinshi.id)
|
||||
|
||||
if not options.is_nohtml and not options.is_cbz and not options.is_pdf:
|
||||
generate_html(options.output_dir, doujinshi)
|
||||
generate_html(options.output_dir, doujinshi, template=constant.CONFIG['template'])
|
||||
elif options.is_cbz:
|
||||
generate_cbz(options.output_dir, doujinshi, options.rm_origin_dir)
|
||||
elif options.is_pdf:
|
||||
|
@ -33,5 +33,6 @@ CONFIG = {
|
||||
'proxy': {},
|
||||
'cookie': '',
|
||||
'language': '',
|
||||
'template': '',
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ def readfile(path):
|
||||
return file.read()
|
||||
|
||||
|
||||
def generate_html(output_dir='.', doujinshi_obj=None):
|
||||
def generate_html(output_dir='.', doujinshi_obj=None, template='default'):
|
||||
image_html = ''
|
||||
|
||||
if doujinshi_obj is not None:
|
||||
@ -81,9 +81,9 @@ def generate_html(output_dir='.', doujinshi_obj=None):
|
||||
|
||||
image_html += '<img src="{0}" class="image-item"/>\n'\
|
||||
.format(image)
|
||||
html = readfile('viewer/index.html')
|
||||
css = readfile('viewer/styles.css')
|
||||
js = readfile('viewer/scripts.js')
|
||||
html = readfile('viewer/{}/index.html'.format(template))
|
||||
css = readfile('viewer/{}/styles.css'.format(template))
|
||||
js = readfile('viewer/{}/scripts.js'.format(template))
|
||||
|
||||
if doujinshi_obj is not None:
|
||||
serialize_json(doujinshi_obj, doujinshi_dir)
|
||||
|
Loading…
x
Reference in New Issue
Block a user