mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-07-01 16:09:28 +02:00
Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
cac07a517e | |||
f30ff59b2b | |||
1504ee779f | |||
98d9eecf6d | |||
e16e623b9d | |||
c3f3182df3 | |||
12aad842f8 | |||
f9f76ab0f5 | |||
744a9e4418 | |||
c3e9fff491 | |||
a84e2c5714 | |||
c814c35c50 | |||
e2f71437e2 | |||
2fa45ae4df |
@ -1,3 +1,3 @@
|
|||||||
__version__ = '0.5.9'
|
__version__ = '0.5.12'
|
||||||
__author__ = 'RicterZ'
|
__author__ = 'RicterZ'
|
||||||
__email__ = 'ricterzheng@gmail.com'
|
__email__ = 'ricterzheng@gmail.com'
|
||||||
|
@ -38,9 +38,9 @@ FAV_URL = f'{BASE_URL}/favorites/'
|
|||||||
|
|
||||||
IMAGE_URL = f'{urlparse(BASE_URL).scheme}://i.{urlparse(BASE_URL).hostname}/galleries'
|
IMAGE_URL = f'{urlparse(BASE_URL).scheme}://i.{urlparse(BASE_URL).hostname}/galleries'
|
||||||
IMAGE_URL_MIRRORS = [
|
IMAGE_URL_MIRRORS = [
|
||||||
f'{urlparse(BASE_URL).scheme}://i3.{urlparse(BASE_URL).hostname}'
|
f'{urlparse(BASE_URL).scheme}://i3.{urlparse(BASE_URL).hostname}',
|
||||||
f'{urlparse(BASE_URL).scheme}://i5.{urlparse(BASE_URL).hostname}'
|
f'{urlparse(BASE_URL).scheme}://i5.{urlparse(BASE_URL).hostname}',
|
||||||
f'{urlparse(BASE_URL).scheme}://i7.{urlparse(BASE_URL).hostname}'
|
f'{urlparse(BASE_URL).scheme}://i7.{urlparse(BASE_URL).hostname}',
|
||||||
]
|
]
|
||||||
|
|
||||||
NHENTAI_HOME = get_nhentai_home()
|
NHENTAI_HOME = get_nhentai_home()
|
||||||
|
@ -12,6 +12,7 @@ EXT_MAP = {
|
|||||||
'j': 'jpg',
|
'j': 'jpg',
|
||||||
'p': 'png',
|
'p': 'png',
|
||||||
'g': 'gif',
|
'g': 'gif',
|
||||||
|
'w': 'webp',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -89,7 +90,8 @@ class Doujinshi(object):
|
|||||||
if options.is_cbz:
|
if options.is_cbz:
|
||||||
ret_cbz = os.path.exists(f'{base_path}.cbz') or os.path.exists(f'{base_path}/{self.filename}.cbz')
|
ret_cbz = os.path.exists(f'{base_path}.cbz') or os.path.exists(f'{base_path}/{self.filename}.cbz')
|
||||||
|
|
||||||
if all(filter(lambda s: s is not None, [ret_cbz, ret_pdf])):
|
ret = list(filter(lambda s: s is not None, [ret_cbz, ret_pdf]))
|
||||||
|
if ret and all(ret):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# doujinshi directory doesn't exist, re-download
|
# doujinshi directory doesn't exist, re-download
|
||||||
|
@ -69,7 +69,7 @@ class Downloader(Singleton):
|
|||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
path = urlparse(url).path
|
path = urlparse(url).path
|
||||||
for mirror in constant.IMAGE_URL_MIRRORS:
|
for mirror in constant.IMAGE_URL_MIRRORS:
|
||||||
print(f'{mirror}{path}')
|
# print(f'{mirror}{path}')
|
||||||
mirror_url = f'{mirror}{path}'
|
mirror_url = f'{mirror}{path}'
|
||||||
response = request('get', mirror_url, stream=True,
|
response = request('get', mirror_url, stream=True,
|
||||||
timeout=self.timeout, proxies=proxy)
|
timeout=self.timeout, proxies=proxy)
|
||||||
|
@ -148,7 +148,7 @@ def doujinshi_parser(id_, counter=0):
|
|||||||
doujinshi['subtitle'] = subtitle.text if subtitle else ''
|
doujinshi['subtitle'] = subtitle.text if subtitle else ''
|
||||||
|
|
||||||
doujinshi_cover = html.find('div', attrs={'id': 'cover'})
|
doujinshi_cover = html.find('div', attrs={'id': 'cover'})
|
||||||
img_id = re.search('/galleries/([0-9]+)/cover.(jpg|png|gif)$',
|
img_id = re.search('/galleries/([0-9]+)/cover.(jpg|png|gif|webp)$',
|
||||||
doujinshi_cover.a.img.attrs['data-src'])
|
doujinshi_cover.a.img.attrs['data-src'])
|
||||||
|
|
||||||
ext = []
|
ext = []
|
||||||
|
@ -104,7 +104,7 @@ def generate_html(output_dir='.', doujinshi_obj=None, template='default'):
|
|||||||
file_list.sort()
|
file_list.sort()
|
||||||
|
|
||||||
for image in file_list:
|
for image in file_list:
|
||||||
if not os.path.splitext(image)[1] in ('.jpg', '.png'):
|
if not os.path.splitext(image)[1] in ('.jpg', '.png', '.webp'):
|
||||||
continue
|
continue
|
||||||
image_html += f'<img src="{image}" class="image-item"/>\n'
|
image_html += f'<img src="{image}" class="image-item"/>\n'
|
||||||
|
|
||||||
@ -230,7 +230,7 @@ def generate_doc(file_type='', output_dir='.', doujinshi_obj=None, regenerate=Fa
|
|||||||
import img2pdf
|
import img2pdf
|
||||||
|
|
||||||
"""Write images to a PDF file using img2pdf."""
|
"""Write images to a PDF file using img2pdf."""
|
||||||
file_list = [f for f in os.listdir(doujinshi_dir) if f.lower().endswith(('.png', '.jpg', '.jpeg', '.gif'))]
|
file_list = [f for f in os.listdir(doujinshi_dir) if f.lower().endswith(('.png', '.jpg', '.jpeg', '.gif', '.webp'))]
|
||||||
file_list.sort()
|
file_list.sort()
|
||||||
|
|
||||||
logger.info(f'Writing PDF file to path: {filename}')
|
logger.info(f'Writing PDF file to path: {filename}')
|
||||||
@ -309,7 +309,7 @@ def generate_metadata_file(output_dir, doujinshi_obj):
|
|||||||
'TRANSLATOR', 'PUBLISHER', 'DESCRIPTION', 'STATUS', 'CHAPTERS', 'PAGES',
|
'TRANSLATOR', 'PUBLISHER', 'DESCRIPTION', 'STATUS', 'CHAPTERS', 'PAGES',
|
||||||
'TAGS', 'TYPE', 'LANGUAGE', 'RELEASED', 'READING DIRECTION', 'CHARACTERS',
|
'TAGS', 'TYPE', 'LANGUAGE', 'RELEASED', 'READING DIRECTION', 'CHARACTERS',
|
||||||
'SERIES', 'PARODY', 'URL']
|
'SERIES', 'PARODY', 'URL']
|
||||||
special_fields = ['PARODY', 'TITLE', 'ORIGINAL TITLE', 'CHARACTERS', 'AUTHOR', 'GROUPS',
|
special_fields = ['PARODY', 'TITLE', 'ORIGINAL TITLE', 'DATE', 'CHARACTERS', 'AUTHOR', 'GROUPS',
|
||||||
'LANGUAGE', 'TAGS', 'URL', 'PAGES']
|
'LANGUAGE', 'TAGS', 'URL', 'PAGES']
|
||||||
|
|
||||||
for i in range(len(fields)):
|
for i in range(len(fields)):
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "nhentai"
|
name = "nhentai"
|
||||||
version = "0.5.9"
|
version = "0.5.12"
|
||||||
description = "nhentai doujinshi downloader"
|
description = "nhentai doujinshi downloader"
|
||||||
authors = ["Ricter Z <ricterzheng@gmail.com>"]
|
authors = ["Ricter Z <ricterzheng@gmail.com>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
Reference in New Issue
Block a user