Skip to content

Commit

Permalink
fix #369
Browse files Browse the repository at this point in the history
  • Loading branch information
RicterZ committed Jan 10, 2025
1 parent d74fd10 commit 54af682
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions nhentai/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def start_download(self, queue, folder='') -> bool:
return True

digit_length = len(str(len(queue)))
logger.info(f'Total download pages: {len(queue)}')
coroutines = [
self._semaphore_download(url, filename=os.path.basename(urlparse(url).path), length=digit_length)
for url in queue
Expand Down
5 changes: 3 additions & 2 deletions nhentai/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from nhentai.serializer import serialize_json, serialize_comic_xml, set_js_database

MAX_FIELD_LENGTH = 100
EXTENSIONS = ('.png', '.jpg', '.jpeg', '.gif', '.webp')


def request(method, url, **kwargs):
Expand Down Expand Up @@ -130,7 +131,7 @@ def generate_html(output_dir='.', doujinshi_obj=None, template='default'):
file_list.sort()

for image in file_list:
if not os.path.splitext(image)[1] in ('.jpg', '.png', '.webp'):
if not os.path.splitext(image)[1] in EXTENSIONS:
continue
image_html += f'<img src="{image}" class="image-item"/>\n'

Expand Down Expand Up @@ -256,7 +257,7 @@ def generate_doc(file_type='', output_dir='.', doujinshi_obj=None, regenerate=Fa
import 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', '.webp'))]
file_list = [f for f in os.listdir(doujinshi_dir) if f.lower().endswith(EXTENSIONS)]
file_list.sort()

logger.info(f'Writing PDF file to path: {filename}')
Expand Down

0 comments on commit 54af682

Please sign in to comment.