mirror of
				https://github.com/RicterZ/nhentai.git
				synced 2025-11-04 11:00:55 +01:00 
			
		
		
		
	Merge branch 'master' into dependabot/pip/idna-3.7
This commit is contained in:
		@@ -1,3 +1,3 @@
 | 
				
			|||||||
__version__ = '0.5.5'
 | 
					__version__ = '0.5.6'
 | 
				
			||||||
__author__ = 'RicterZ'
 | 
					__author__ = 'RicterZ'
 | 
				
			||||||
__email__ = 'ricterzheng@gmail.com'
 | 
					__email__ = 'ricterzheng@gmail.com'
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,6 +3,23 @@ import os
 | 
				
			|||||||
import tempfile
 | 
					import tempfile
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from urllib.parse import urlparse
 | 
					from urllib.parse import urlparse
 | 
				
			||||||
 | 
					from platform import system
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def get_nhentai_home() -> str:
 | 
				
			||||||
 | 
					    home = os.getenv('HOME', tempfile.gettempdir())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if system() == 'Linux':
 | 
				
			||||||
 | 
					        xdgdat = os.getenv('XDG_DATA_HOME')
 | 
				
			||||||
 | 
					        if xdgdat and os.path.exists(os.path.join(xdgdat, 'nhentai')):
 | 
				
			||||||
 | 
					            return os.path.join(xdgdat, 'nhentai')
 | 
				
			||||||
 | 
					        if home and os.path.exists(os.path.join(home, '.nhentai')):
 | 
				
			||||||
 | 
					            return os.path.join(home, '.nhentai')
 | 
				
			||||||
 | 
					        if xdgdat:
 | 
				
			||||||
 | 
					            return os.path.join(xdgdat, 'nhentai')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Use old default path in other systems
 | 
				
			||||||
 | 
					    return os.path.join(home, '.nhentai')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DEBUG = os.getenv('DEBUG', False)
 | 
					DEBUG = os.getenv('DEBUG', False)
 | 
				
			||||||
@@ -20,8 +37,13 @@ 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 = [
 | 
				
			||||||
 | 
					    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}://i7.{urlparse(BASE_URL).hostname}'
 | 
				
			||||||
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
NHENTAI_HOME = os.path.join(os.getenv('HOME', tempfile.gettempdir()), '.nhentai')
 | 
					NHENTAI_HOME = get_nhentai_home()
 | 
				
			||||||
NHENTAI_HISTORY = os.path.join(NHENTAI_HOME, 'history.sqlite3')
 | 
					NHENTAI_HISTORY = os.path.join(NHENTAI_HOME, 'history.sqlite3')
 | 
				
			||||||
NHENTAI_CONFIG_FILE = os.path.join(NHENTAI_HOME, 'config.json')
 | 
					NHENTAI_CONFIG_FILE = os.path.join(NHENTAI_HOME, 'config.json')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -32,7 +54,8 @@ CONFIG = {
 | 
				
			|||||||
    'cookie': '',
 | 
					    'cookie': '',
 | 
				
			||||||
    'language': '',
 | 
					    'language': '',
 | 
				
			||||||
    'template': '',
 | 
					    'template': '',
 | 
				
			||||||
    'useragent': 'nhentai command line client (https://github.com/RicterZ/nhentai)'
 | 
					    'useragent': 'nhentai command line client (https://github.com/RicterZ/nhentai)',
 | 
				
			||||||
 | 
					    'max_filename': 85
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
LANGUAGE_ISO = {
 | 
					LANGUAGE_ISO = {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -67,10 +67,14 @@ class Downloader(Singleton):
 | 
				
			|||||||
                    try:
 | 
					                    try:
 | 
				
			||||||
                        response = request('get', url, stream=True, timeout=self.timeout, proxies=proxy)
 | 
					                        response = request('get', url, stream=True, timeout=self.timeout, proxies=proxy)
 | 
				
			||||||
                        if response.status_code != 200:
 | 
					                        if response.status_code != 200:
 | 
				
			||||||
                            raise NHentaiImageNotExistException
 | 
					                            path = urlparse(url).path
 | 
				
			||||||
 | 
					                            for mirror in constant.IMAGE_URL_MIRRORS:
 | 
				
			||||||
                    except NHentaiImageNotExistException as e:
 | 
					                                print(f'{mirror}{path}')
 | 
				
			||||||
                        raise e
 | 
					                                mirror_url = f'{mirror}{path}'
 | 
				
			||||||
 | 
					                                response = request('get', mirror_url, stream=True,
 | 
				
			||||||
 | 
					                                                   timeout=self.timeout, proxies=proxy)
 | 
				
			||||||
 | 
					                                if response.status_code == 200:
 | 
				
			||||||
 | 
					                                    break
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    except Exception as e:
 | 
					                    except Exception as e:
 | 
				
			||||||
                        i += 1
 | 
					                        i += 1
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -135,7 +135,7 @@ def doujinshi_parser(id_, counter=0):
 | 
				
			|||||||
        logger.warning(f'Error: {e}, ignored')
 | 
					        logger.warning(f'Error: {e}, ignored')
 | 
				
			||||||
        return None
 | 
					        return None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    print(response)
 | 
					    # print(response)
 | 
				
			||||||
    html = BeautifulSoup(response, 'html.parser')
 | 
					    html = BeautifulSoup(response, 'html.parser')
 | 
				
			||||||
    doujinshi_info = html.find('div', attrs={'id': 'info'})
 | 
					    doujinshi_info = html.find('div', attrs={'id': 'info'})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -327,7 +327,9 @@ def search_parser(keyword, sorting, page, is_page_all=False):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        for row in response['result']:
 | 
					        for row in response['result']:
 | 
				
			||||||
            title = row['title']['english']
 | 
					            title = row['title']['english']
 | 
				
			||||||
            title = title[:85] + '..' if len(title) > 85 else title
 | 
					            title = title[:constant.CONFIG['max_filename']] + '..' if \
 | 
				
			||||||
 | 
					                len(title) > constant.CONFIG['max_filename'] else title
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            result.append({'id': row['id'], 'title': title})
 | 
					            result.append({'id': row['id'], 'title': title})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        not_exists_persist = False
 | 
					        not_exists_persist = False
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -209,9 +209,10 @@ def generate_pdf(output_dir='.', doujinshi_obj=None, rm_origin_dir=False, move_t
 | 
				
			|||||||
        """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)
 | 
				
			||||||
 | 
					            filename = doujinshi_obj.filename.replace('/', '-')
 | 
				
			||||||
            pdf_filename = os.path.join(
 | 
					            pdf_filename = os.path.join(
 | 
				
			||||||
                os.path.join(doujinshi_dir, '..'),
 | 
					                os.path.join(doujinshi_dir, '..'),
 | 
				
			||||||
                f'{doujinshi_obj.filename}.pdf'
 | 
					                f'{filename}.pdf'
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            pdf_filename = './doujinshi.pdf'
 | 
					            pdf_filename = './doujinshi.pdf'
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -139,7 +139,7 @@ function filter_searcher(){
 | 
				
			|||||||
					break
 | 
										break
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (verifier){doujinshi_id.push(data[i].Folder);}
 | 
							if (verifier){doujinshi_id.push(data[i].Folder.replace("_", " "));}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	var gallery = document.getElementsByClassName("gallery-favorite");
 | 
						var gallery = document.getElementsByClassName("gallery-favorite");
 | 
				
			||||||
	for (var i = 0; i < gallery.length; i++){
 | 
						for (var i = 0; i < gallery.length; i++){
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										24
									
								
								poetry.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										24
									
								
								poetry.lock
									
									
									
										generated
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand.
 | 
					# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[[package]]
 | 
					[[package]]
 | 
				
			||||||
name = "beautifulsoup4"
 | 
					name = "beautifulsoup4"
 | 
				
			||||||
@@ -20,13 +20,13 @@ lxml = ["lxml"]
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
[[package]]
 | 
					[[package]]
 | 
				
			||||||
name = "certifi"
 | 
					name = "certifi"
 | 
				
			||||||
version = "2022.12.7"
 | 
					version = "2024.7.4"
 | 
				
			||||||
description = "Python package for providing Mozilla's CA Bundle."
 | 
					description = "Python package for providing Mozilla's CA Bundle."
 | 
				
			||||||
optional = false
 | 
					optional = false
 | 
				
			||||||
python-versions = ">=3.6"
 | 
					python-versions = ">=3.6"
 | 
				
			||||||
files = [
 | 
					files = [
 | 
				
			||||||
    {file = "certifi-2022.12.7-py3-none-any.whl", hash = "sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18"},
 | 
					    {file = "certifi-2024.7.4-py3-none-any.whl", hash = "sha256:c198e21b1289c2ab85ee4e67bb4b4ef3ead0892059901a8d5b622f24a1101e90"},
 | 
				
			||||||
    {file = "certifi-2022.12.7.tar.gz", hash = "sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3"},
 | 
					    {file = "certifi-2024.7.4.tar.gz", hash = "sha256:5a1e7645bc0ec61a09e26c36f6106dd4cf40c6db3a1fb6352b0244e7fb057c7b"},
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[[package]]
 | 
					[[package]]
 | 
				
			||||||
@@ -150,13 +150,13 @@ files = [
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
[[package]]
 | 
					[[package]]
 | 
				
			||||||
name = "requests"
 | 
					name = "requests"
 | 
				
			||||||
version = "2.31.0"
 | 
					version = "2.32.0"
 | 
				
			||||||
description = "Python HTTP for Humans."
 | 
					description = "Python HTTP for Humans."
 | 
				
			||||||
optional = false
 | 
					optional = false
 | 
				
			||||||
python-versions = ">=3.7"
 | 
					python-versions = ">=3.8"
 | 
				
			||||||
files = [
 | 
					files = [
 | 
				
			||||||
    {file = "requests-2.31.0-py3-none-any.whl", hash = "sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f"},
 | 
					    {file = "requests-2.32.0-py3-none-any.whl", hash = "sha256:f2c3881dddb70d056c5bd7600a4fae312b2a300e39be6a118d30b90bd27262b5"},
 | 
				
			||||||
    {file = "requests-2.31.0.tar.gz", hash = "sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1"},
 | 
					    {file = "requests-2.32.0.tar.gz", hash = "sha256:fa5490319474c82ef1d2c9bc459d3652e3ae4ef4c4ebdd18a21145a47ca4b6b8"},
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[package.dependencies]
 | 
					[package.dependencies]
 | 
				
			||||||
@@ -196,13 +196,13 @@ widechars = ["wcwidth"]
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
[[package]]
 | 
					[[package]]
 | 
				
			||||||
name = "urllib3"
 | 
					name = "urllib3"
 | 
				
			||||||
version = "1.26.18"
 | 
					version = "1.26.19"
 | 
				
			||||||
description = "HTTP library with thread-safe connection pooling, file post, and more."
 | 
					description = "HTTP library with thread-safe connection pooling, file post, and more."
 | 
				
			||||||
optional = false
 | 
					optional = false
 | 
				
			||||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*"
 | 
					python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7"
 | 
				
			||||||
files = [
 | 
					files = [
 | 
				
			||||||
    {file = "urllib3-1.26.18-py2.py3-none-any.whl", hash = "sha256:34b97092d7e0a3a8cf7cd10e386f401b3737364026c45e622aa02903dffe0f07"},
 | 
					    {file = "urllib3-1.26.19-py2.py3-none-any.whl", hash = "sha256:37a0344459b199fce0e80b0d3569837ec6b6937435c5244e7fd73fa6006830f3"},
 | 
				
			||||||
    {file = "urllib3-1.26.18.tar.gz", hash = "sha256:f8ecc1bba5667413457c529ab955bf8c67b45db799d159066261719e328580a0"},
 | 
					    {file = "urllib3-1.26.19.tar.gz", hash = "sha256:3e3d753a8618b86d7de333b4223005f68720bcd6a7d2bcb9fbd2229ec7c1e429"},
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[package.extras]
 | 
					[package.extras]
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user