From d2e68c6c45f11079ce588c64f91a7af1c4cc4460 Mon Sep 17 00:00:00 2001 From: Ricter Z Date: Fri, 2 Oct 2020 00:51:37 +0800 Subject: [PATCH 1/8] fix #146 #142 #146 --- nhentai/utils.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/nhentai/utils.py b/nhentai/utils.py index caa925b..d4b8183 100644 --- a/nhentai/utils.py +++ b/nhentai/utils.py @@ -233,8 +233,6 @@ and append a file extension like '.txt', so I avoid the potential of using an invalid filename. """ - return s - # maybe you can use `--format` to select a suitable filename valid_chars = "-_.()[] %s%s" % (string.ascii_letters, string.digits) filename = ''.join(c for c in s if c in valid_chars) From 7570b6ae7d1c4bd1a4f4f3d2247b1e891340a196 Mon Sep 17 00:00:00 2001 From: Ricter Z Date: Fri, 2 Oct 2020 00:55:26 +0800 Subject: [PATCH 2/8] remove img2pdf in requirements --- nhentai/utils.py | 6 +++++- requirements.txt | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/nhentai/utils.py b/nhentai/utils.py index d4b8183..e8626b9 100644 --- a/nhentai/utils.py +++ b/nhentai/utils.py @@ -9,7 +9,6 @@ import zipfile import shutil import requests import sqlite3 -import img2pdf from nhentai import constant from nhentai.logger import logger @@ -195,6 +194,11 @@ def generate_cbz(output_dir='.', doujinshi_obj=None, rm_origin_dir=False, write_ def generate_pdf(output_dir='.', doujinshi_obj=None, rm_origin_dir=False): + try: + import img2pdf + except ImportError: + logger.error("Please install img2pdf package by using pip.") + """Write images to a PDF file using img2pdf.""" if doujinshi_obj is not None: doujinshi_dir = os.path.join(output_dir, doujinshi_obj.filename) diff --git a/requirements.txt b/requirements.txt index e34829d..3fbad9d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,5 +4,4 @@ BeautifulSoup4>=4.0.0 threadpool>=1.2.7 tabulate>=0.7.5 future>=0.15.2 -img2pdf>=0.3.6 iso8601 >= 0.1 From 91053b98af2528302693b453859986bef9d9a220 Mon Sep 17 00:00:00 2001 From: Ricter Z Date: Fri, 2 Oct 2020 01:02:41 +0800 Subject: [PATCH 3/8] 0.4.1 --- nhentai/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nhentai/__init__.py b/nhentai/__init__.py index e622c47..7efe343 100644 --- a/nhentai/__init__.py +++ b/nhentai/__init__.py @@ -1,3 +1,3 @@ -__version__ = '0.4.0' +__version__ = '0.4.1' __author__ = 'RicterZ' __email__ = 'ricterzheng@gmail.com' From b3f25875d0aa6f537f43259e6c64e4b017d0d566 Mon Sep 17 00:00:00 2001 From: Ricter Z Date: Fri, 2 Oct 2020 01:32:18 +0800 Subject: [PATCH 4/8] fix bug on mac #126 --- nhentai/downloader.py | 13 +++++-------- nhentai/parser.py | 1 - 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/nhentai/downloader.py b/nhentai/downloader.py index 2d9a0f4..f11bb60 100644 --- a/nhentai/downloader.py +++ b/nhentai/downloader.py @@ -5,11 +5,10 @@ import multiprocessing import signal from future.builtins import str as text +import sys import os import requests -import threadpool import time -import multiprocessing as mp try: from urllib.parse import urlparse @@ -18,10 +17,10 @@ except ImportError: from nhentai.logger import logger from nhentai.parser import request -from nhentai.utils import Singleton, signal_handler +from nhentai.utils import Singleton requests.packages.urllib3.disable_warnings() -semaphore = mp.Semaphore() +semaphore = multiprocessing.Semaphore(1) class NHentaiImageNotExistException(Exception): @@ -133,16 +132,14 @@ class Downloader(Singleton): queue = [(self, url, folder) for url in queue] pool = multiprocessing.Pool(self.size, init_worker) - - for item in queue: - pool.apply_async(download_wrapper, args=item, callback=self._download_callback) + [pool.apply_async(download_wrapper, args=item) for item in queue] pool.close() pool.join() def download_wrapper(obj, url, folder=''): - if semaphore.get_value(): + if sys.platform == 'darwin' or semaphore.get_value(): return Downloader.download_(obj, url=url, folder=folder) else: return -3, None diff --git a/nhentai/parser.py b/nhentai/parser.py index 97c1b15..93dd109 100644 --- a/nhentai/parser.py +++ b/nhentai/parser.py @@ -178,7 +178,6 @@ def doujinshi_parser(id_): doujinshi['img_id'] = img_id.group(1) doujinshi['ext'] = ext - pages = 0 for _ in doujinshi_info.find_all('div', class_='tag-container field-name'): if re.search('Pages:', _.text): pages = _.find('span', class_='name').string From c5e4b5ffa8b31eab073693fc59496a6ae8efa252 Mon Sep 17 00:00:00 2001 From: Ricter Z Date: Fri, 2 Oct 2020 01:39:14 +0800 Subject: [PATCH 5/8] update --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 7b87d5c..f8a586d 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ setup( author=__author__, author_email=__email__, - keywords='nhentai, doujinshi', + keywords=['nhentai', 'doujinshi', 'downloader'] description='nhentai.net doujinshis downloader', long_description=long_description(), url='https://github.com/RicterZ/nhentai', From 14a53a09534947428368d2c392d2918a41f5383c Mon Sep 17 00:00:00 2001 From: Ricter Z Date: Fri, 2 Oct 2020 01:39:42 +0800 Subject: [PATCH 6/8] fix --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f8a586d..8218604 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ setup( author=__author__, author_email=__email__, - keywords=['nhentai', 'doujinshi', 'downloader'] + keywords=['nhentai', 'doujinshi', 'downloader'], description='nhentai.net doujinshis downloader', long_description=long_description(), url='https://github.com/RicterZ/nhentai', From eb35ba9848939dafc6801ad053492ed324d870a7 Mon Sep 17 00:00:00 2001 From: Ricter Z Date: Fri, 2 Oct 2020 01:41:02 +0800 Subject: [PATCH 7/8] 0.4.2 --- nhentai/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nhentai/__init__.py b/nhentai/__init__.py index 7efe343..5561dc3 100644 --- a/nhentai/__init__.py +++ b/nhentai/__init__.py @@ -1,3 +1,3 @@ -__version__ = '0.4.1' +__version__ = '0.4.2' __author__ = 'RicterZ' __email__ = 'ricterzheng@gmail.com' From 5a538fe82f589d635649f51e755c5a4fd537432e Mon Sep 17 00:00:00 2001 From: Ricter Z Date: Fri, 2 Oct 2020 01:43:44 +0800 Subject: [PATCH 8/8] add tests and new python version --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 98f81ad..690e557 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,13 +4,14 @@ os: language: python python: - 3.7 + - 3.8 install: - python setup.py install script: - echo 268642 > /tmp/test.txt - - nhentai --cookie "_ga=GA1.2.2000087053.1558179358; __cfduid=d8930f7b43d04e1b2117719e28386b2e31593148489; csrftoken=3914GQGSmmqQyfQTBswNgfXuhFiefu8sAgOnsfZWiiqS4PJpKivuTp34p2USV6xu; sessionid=be0w2lwlprlmld3ahg9i592ipsuaw840" + - nhentai --cookie "_ga=GA1.2.1651446371.1545407218; __cfduid=d0ed34dfb81167d2a51a1d6392c1768a81601380350; csrftoken=KRN0GR1ft86m3HTefpQA99pp6R1Bo7hUs5QxNGOAIuwB5g4EcJj04fwMB8QKgLaB; sessionid=7hzoowox78c90wi5ud5ibphm4axcck7c" - nhentai --search umaru - nhentai --id=152503,146134 -t 10 --output=/tmp/ --cbz - nhentai -F