mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-07-01 16:09:28 +02:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
248d31edf0 | |||
4bfe0de078 | |||
780a6c82b2 | |||
8791e7af55 | |||
b434c4d58d |
@ -136,6 +136,8 @@ Format output doujinshi folder name:
|
||||
.. code-block:: bash
|
||||
|
||||
nhentai --id 261100 --format '[%i]%s'
|
||||
# for Windows
|
||||
nhentai --id 261100 --format "[%%i]%%s"
|
||||
|
||||
Supported doujinshi folder formatter:
|
||||
|
||||
@ -148,6 +150,7 @@ Supported doujinshi folder formatter:
|
||||
- %p: Doujinshi pretty name
|
||||
- %ag: Doujinshi authors name or groups name
|
||||
|
||||
Note: for Windows operation system, please use double "%", such as "%%i".
|
||||
|
||||
Other options:
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
__version__ = '0.5.20'
|
||||
__version__ = '0.5.22'
|
||||
__author__ = 'RicterZ'
|
||||
__email__ = 'ricterzheng@gmail.com'
|
||||
|
@ -131,6 +131,8 @@ def cmd_parser():
|
||||
help='generate a metadata file in doujinshi format')
|
||||
parser.add_option('--regenerate', dest='regenerate', action='store_true', default=False,
|
||||
help='regenerate the cbz or pdf file if exists')
|
||||
parser.add_option('--no-metadata', dest='no_metadata', action='store_true', default=False,
|
||||
help='don\'t generate metadata json file in doujinshi output path')
|
||||
|
||||
# nhentai options
|
||||
parser.add_option('--cookie', type='str', dest='cookie', action='store',
|
||||
|
@ -15,6 +15,7 @@ from nhentai.doujinshi import Doujinshi
|
||||
from nhentai.downloader import Downloader
|
||||
from nhentai.logger import logger
|
||||
from nhentai.constant import BASE_URL
|
||||
from nhentai.serializer import serialize_json
|
||||
from nhentai.utils import generate_html, generate_doc, generate_main_html, generate_metadata_file, \
|
||||
paging, check_cookie, signal_handler, DB, move_to_folder
|
||||
|
||||
@ -115,6 +116,9 @@ def main():
|
||||
if not options.is_nohtml:
|
||||
generate_html(options.output_dir, doujinshi, template=constant.CONFIG['template'])
|
||||
|
||||
if not options.no_metadata:
|
||||
generate_doc('json', options.output_dir, doujinshi, options.regenerate)
|
||||
|
||||
if options.is_cbz:
|
||||
generate_doc('cbz', options.output_dir, doujinshi, options.regenerate)
|
||||
|
||||
|
@ -141,12 +141,12 @@ def doujinshi_parser(id_, counter=0):
|
||||
title = doujinshi_info.find('h1').text
|
||||
pretty_name = doujinshi_info.find('h1').find('span', attrs={'class': 'pretty'}).text
|
||||
subtitle = doujinshi_info.find('h2')
|
||||
favorite_counts = doujinshi_info.find('span', class_='nobold').find('span', class_='count')
|
||||
favorite_counts = doujinshi_info.find('span', class_='nobold').text.strip('(').strip(')')
|
||||
|
||||
doujinshi['name'] = title
|
||||
doujinshi['pretty_name'] = pretty_name
|
||||
doujinshi['subtitle'] = subtitle.text if subtitle else ''
|
||||
doujinshi['favorite_counts'] = int(favorite_counts.text.strip()) if favorite_counts else 0
|
||||
doujinshi['favorite_counts'] = int(favorite_counts) if favorite_counts and favorite_counts.isdigit() else 0
|
||||
|
||||
doujinshi_cover = html.find('div', attrs={'id': 'cover'})
|
||||
# img_id = re.search('/galleries/([0-9]+)/cover.(jpg|png|gif|webp)$',
|
||||
|
@ -2,12 +2,11 @@
|
||||
import json
|
||||
import os
|
||||
|
||||
from nhentai.constant import PATH_SEPARATOR
|
||||
from nhentai.constant import PATH_SEPARATOR, LANGUAGE_ISO
|
||||
from xml.sax.saxutils import escape
|
||||
from nhentai.constant import LANGUAGE_ISO
|
||||
|
||||
|
||||
def serialize_json(doujinshi, output_dir):
|
||||
def serialize_json(doujinshi, output_dir: str):
|
||||
metadata = {'title': doujinshi.name,
|
||||
'subtitle': doujinshi.info.subtitle}
|
||||
if doujinshi.info.favorite_counts:
|
||||
|
@ -16,7 +16,7 @@ from requests.structures import CaseInsensitiveDict
|
||||
from nhentai import constant
|
||||
from nhentai.constant import PATH_SEPARATOR
|
||||
from nhentai.logger import logger
|
||||
from nhentai.serializer import serialize_json, serialize_comic_xml, set_js_database
|
||||
from nhentai.serializer import serialize_comic_xml, serialize_json, set_js_database
|
||||
|
||||
MAX_FIELD_LENGTH = 100
|
||||
EXTENSIONS = ('.png', '.jpg', '.jpeg', '.gif', '.webp')
|
||||
@ -142,7 +142,7 @@ def generate_html(output_dir='.', doujinshi_obj=None, template='default'):
|
||||
js = readfile(f'viewer/{template}/scripts.js')
|
||||
|
||||
if doujinshi_obj is not None:
|
||||
serialize_json(doujinshi_obj, doujinshi_dir)
|
||||
# serialize_json(doujinshi_obj, doujinshi_dir)
|
||||
name = doujinshi_obj.name
|
||||
else:
|
||||
name = {'title': 'nHentai HTML Viewer'}
|
||||
@ -274,6 +274,9 @@ def generate_doc(file_type='', output_dir='.', doujinshi_obj=None, regenerate=Fa
|
||||
except ImportError:
|
||||
logger.error("Please install img2pdf package by using pip.")
|
||||
|
||||
elif file_type == 'json':
|
||||
serialize_json(doujinshi_obj, doujinshi_dir)
|
||||
|
||||
|
||||
def format_filename(s, length=MAX_FIELD_LENGTH, _truncate_only=False):
|
||||
"""
|
||||
|
@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "nhentai"
|
||||
version = "0.5.20"
|
||||
version = "0.5.22"
|
||||
description = "nhentai doujinshi downloader"
|
||||
authors = ["Ricter Z <ricterzheng@gmail.com>"]
|
||||
license = "MIT"
|
||||
|
Reference in New Issue
Block a user