mirror of
				https://github.com/RicterZ/nhentai.git
				synced 2025-11-04 02:50:55 +01:00 
			
		
		
		
	@@ -4,13 +4,14 @@ os:
 | 
				
			|||||||
language: python
 | 
					language: python
 | 
				
			||||||
python:
 | 
					python:
 | 
				
			||||||
    - 3.7
 | 
					    - 3.7
 | 
				
			||||||
 | 
					    - 3.8
 | 
				
			||||||
 | 
					
 | 
				
			||||||
install:
 | 
					install:
 | 
				
			||||||
    - python setup.py install
 | 
					    - python setup.py install
 | 
				
			||||||
 | 
					
 | 
				
			||||||
script:
 | 
					script:
 | 
				
			||||||
    - echo 268642 > /tmp/test.txt
 | 
					    - 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 --search umaru
 | 
				
			||||||
    - nhentai --id=152503,146134 -t 10 --output=/tmp/ --cbz
 | 
					    - nhentai --id=152503,146134 -t 10 --output=/tmp/ --cbz
 | 
				
			||||||
    - nhentai -F
 | 
					    - nhentai -F
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,3 +1,3 @@
 | 
				
			|||||||
__version__ = '0.4.0'
 | 
					__version__ = '0.4.2'
 | 
				
			||||||
__author__ = 'RicterZ'
 | 
					__author__ = 'RicterZ'
 | 
				
			||||||
__email__ = 'ricterzheng@gmail.com'
 | 
					__email__ = 'ricterzheng@gmail.com'
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,11 +5,10 @@ import multiprocessing
 | 
				
			|||||||
import signal
 | 
					import signal
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from future.builtins import str as text
 | 
					from future.builtins import str as text
 | 
				
			||||||
 | 
					import sys
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
import requests
 | 
					import requests
 | 
				
			||||||
import threadpool
 | 
					 | 
				
			||||||
import time
 | 
					import time
 | 
				
			||||||
import multiprocessing as mp
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
try:
 | 
					try:
 | 
				
			||||||
    from urllib.parse import urlparse
 | 
					    from urllib.parse import urlparse
 | 
				
			||||||
@@ -18,10 +17,10 @@ except ImportError:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
from nhentai.logger import logger
 | 
					from nhentai.logger import logger
 | 
				
			||||||
from nhentai.parser import request
 | 
					from nhentai.parser import request
 | 
				
			||||||
from nhentai.utils import Singleton, signal_handler
 | 
					from nhentai.utils import Singleton
 | 
				
			||||||
 | 
					
 | 
				
			||||||
requests.packages.urllib3.disable_warnings()
 | 
					requests.packages.urllib3.disable_warnings()
 | 
				
			||||||
semaphore = mp.Semaphore()
 | 
					semaphore = multiprocessing.Semaphore(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class NHentaiImageNotExistException(Exception):
 | 
					class NHentaiImageNotExistException(Exception):
 | 
				
			||||||
@@ -133,16 +132,14 @@ class Downloader(Singleton):
 | 
				
			|||||||
        queue = [(self, url, folder) for url in queue]
 | 
					        queue = [(self, url, folder) for url in queue]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        pool = multiprocessing.Pool(self.size, init_worker)
 | 
					        pool = multiprocessing.Pool(self.size, init_worker)
 | 
				
			||||||
 | 
					        [pool.apply_async(download_wrapper, args=item) for item in queue]
 | 
				
			||||||
        for item in queue:
 | 
					 | 
				
			||||||
            pool.apply_async(download_wrapper, args=item, callback=self._download_callback)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        pool.close()
 | 
					        pool.close()
 | 
				
			||||||
        pool.join()
 | 
					        pool.join()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def download_wrapper(obj, url, folder=''):
 | 
					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)
 | 
					        return Downloader.download_(obj, url=url, folder=folder)
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        return -3, None
 | 
					        return -3, None
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -178,7 +178,6 @@ def doujinshi_parser(id_):
 | 
				
			|||||||
    doujinshi['img_id'] = img_id.group(1)
 | 
					    doujinshi['img_id'] = img_id.group(1)
 | 
				
			||||||
    doujinshi['ext'] = ext
 | 
					    doujinshi['ext'] = ext
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pages = 0
 | 
					 | 
				
			||||||
    for _ in doujinshi_info.find_all('div', class_='tag-container field-name'):
 | 
					    for _ in doujinshi_info.find_all('div', class_='tag-container field-name'):
 | 
				
			||||||
        if re.search('Pages:', _.text):
 | 
					        if re.search('Pages:', _.text):
 | 
				
			||||||
            pages = _.find('span', class_='name').string
 | 
					            pages = _.find('span', class_='name').string
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,7 +9,6 @@ import zipfile
 | 
				
			|||||||
import shutil
 | 
					import shutil
 | 
				
			||||||
import requests
 | 
					import requests
 | 
				
			||||||
import sqlite3
 | 
					import sqlite3
 | 
				
			||||||
import img2pdf
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
from nhentai import constant
 | 
					from nhentai import constant
 | 
				
			||||||
from nhentai.logger import logger
 | 
					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):
 | 
					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."""
 | 
					    """Write images to a PDF file using img2pdf."""
 | 
				
			||||||
    if doujinshi_obj is not None:
 | 
					    if doujinshi_obj is not None:
 | 
				
			||||||
        doujinshi_dir = os.path.join(output_dir, doujinshi_obj.filename)
 | 
					        doujinshi_dir = os.path.join(output_dir, doujinshi_obj.filename)
 | 
				
			||||||
@@ -233,12 +237,6 @@ and append a file extension like '.txt', so I avoid the potential of using
 | 
				
			|||||||
an invalid filename.
 | 
					an invalid filename.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
    if sys.platform.startswith('win32'):
 | 
					 | 
				
			||||||
        invalid_chars = '\/:*?"<>|.'
 | 
					 | 
				
			||||||
        for char in invalid_chars:
 | 
					 | 
				
			||||||
            s = s.replace(char, '_')
 | 
					 | 
				
			||||||
    return s
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    # maybe you can use `--format` to select a suitable filename
 | 
					    # maybe you can use `--format` to select a suitable filename
 | 
				
			||||||
    valid_chars = "-_.()[] %s%s" % (string.ascii_letters, string.digits)
 | 
					    valid_chars = "-_.()[] %s%s" % (string.ascii_letters, string.digits)
 | 
				
			||||||
    filename = ''.join(c for c in s if c in valid_chars)
 | 
					    filename = ''.join(c for c in s if c in valid_chars)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,5 +4,4 @@ BeautifulSoup4>=4.0.0
 | 
				
			|||||||
threadpool>=1.2.7
 | 
					threadpool>=1.2.7
 | 
				
			||||||
tabulate>=0.7.5
 | 
					tabulate>=0.7.5
 | 
				
			||||||
future>=0.15.2
 | 
					future>=0.15.2
 | 
				
			||||||
img2pdf>=0.3.6
 | 
					 | 
				
			||||||
iso8601 >= 0.1
 | 
					iso8601 >= 0.1
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								setup.py
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								setup.py
									
									
									
									
									
								
							@@ -23,7 +23,7 @@ setup(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    author=__author__,
 | 
					    author=__author__,
 | 
				
			||||||
    author_email=__email__,
 | 
					    author_email=__email__,
 | 
				
			||||||
    keywords='nhentai, doujinshi',
 | 
					    keywords=['nhentai', 'doujinshi', 'downloader'],
 | 
				
			||||||
    description='nhentai.net doujinshis downloader',
 | 
					    description='nhentai.net doujinshis downloader',
 | 
				
			||||||
    long_description=long_description(),
 | 
					    long_description=long_description(),
 | 
				
			||||||
    url='https://github.com/RicterZ/nhentai',
 | 
					    url='https://github.com/RicterZ/nhentai',
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user