mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-07-01 16:09:28 +02:00
Compare commits
22 Commits
Author | SHA1 | Date | |
---|---|---|---|
74197f8f90 | |||
6d91a39533 | |||
e181e0b9dd | |||
6fed1f94cb | |||
9cfb23c8ec | |||
fc347cdadf | |||
1cdebaab61 | |||
9513141ccf | |||
bdc9fa113e | |||
36946111db | |||
ce8ae54536 | |||
7aedb905d6 | |||
8b8b5f193e | |||
fc99d91ac1 | |||
ba141efba7 | |||
f78d8750f3 | |||
08bb8ffda4 | |||
af379c825c | |||
2f9386f22c | |||
24f79e0945 | |||
edc46a9531 | |||
72035a14e6 |
@ -1,3 +1,3 @@
|
|||||||
__version__ = '0.4.10'
|
__version__ = '0.4.14'
|
||||||
__author__ = 'RicterZ'
|
__author__ = 'RicterZ'
|
||||||
__email__ = 'ricterzheng@gmail.com'
|
__email__ = 'ricterzheng@gmail.com'
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from __future__ import print_function
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
@ -84,7 +84,7 @@ def cmd_parser():
|
|||||||
help='timeout for downloading doujinshi')
|
help='timeout for downloading doujinshi')
|
||||||
parser.add_option('--delay', '-d', type='int', dest='delay', action='store', default=0,
|
parser.add_option('--delay', '-d', type='int', dest='delay', action='store', default=0,
|
||||||
help='slow down between downloading every doujinshi')
|
help='slow down between downloading every doujinshi')
|
||||||
parser.add_option('--proxy', type='string', dest='proxy', action='store', default='',
|
parser.add_option('--proxy', type='string', dest='proxy', action='store',
|
||||||
help='store a proxy, for example: -p \'http://127.0.0.1:1080\'')
|
help='store a proxy, for example: -p \'http://127.0.0.1:1080\'')
|
||||||
parser.add_option('--file', '-f', type='string', dest='file', action='store', help='read gallery IDs from file.')
|
parser.add_option('--file', '-f', type='string', dest='file', action='store', help='read gallery IDs from file.')
|
||||||
parser.add_option('--format', type='string', dest='name_format', action='store',
|
parser.add_option('--format', type='string', dest='name_format', action='store',
|
||||||
@ -120,7 +120,6 @@ def cmd_parser():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
sys.argv = [unicode(i.decode(sys.stdin.encoding)) for i in sys.argv]
|
sys.argv = [unicode(i.decode(sys.stdin.encoding)) for i in sys.argv]
|
||||||
print()
|
|
||||||
except (NameError, TypeError):
|
except (NameError, TypeError):
|
||||||
pass
|
pass
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
@ -157,7 +156,7 @@ def cmd_parser():
|
|||||||
exit(0)
|
exit(0)
|
||||||
# TODO: search without language
|
# TODO: search without language
|
||||||
|
|
||||||
if args.proxy:
|
if args.proxy is not None:
|
||||||
proxy_url = urlparse(args.proxy)
|
proxy_url = urlparse(args.proxy)
|
||||||
if not args.proxy == '' and proxy_url.scheme not in ('http', 'https'):
|
if not args.proxy == '' and proxy_url.scheme not in ('http', 'https'):
|
||||||
logger.error('Invalid protocol \'{0}\' of proxy, ignored'.format(proxy_url.scheme))
|
logger.error('Invalid protocol \'{0}\' of proxy, ignored'.format(proxy_url.scheme))
|
||||||
@ -171,7 +170,7 @@ def cmd_parser():
|
|||||||
write_config()
|
write_config()
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
if args.viewer_template:
|
if args.viewer_template is not None:
|
||||||
if not args.viewer_template:
|
if not args.viewer_template:
|
||||||
args.viewer_template = 'default'
|
args.viewer_template = 'default'
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python2.7
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from __future__ import unicode_literals, print_function
|
|
||||||
import sys
|
import sys
|
||||||
import signal
|
import signal
|
||||||
import platform
|
import platform
|
||||||
@ -19,6 +19,11 @@ from nhentai.utils import generate_html, generate_cbz, generate_main_html, gener
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
banner()
|
banner()
|
||||||
|
|
||||||
|
if sys.version_info < (3, 0, 0):
|
||||||
|
logger.error('nhentai now only support Python 3.x')
|
||||||
|
exit(1)
|
||||||
|
|
||||||
options = cmd_parser()
|
options = cmd_parser()
|
||||||
logger.info('Using mirror: {0}'.format(BASE_URL))
|
logger.info('Using mirror: {0}'.format(BASE_URL))
|
||||||
|
|
||||||
@ -114,8 +119,4 @@ signal.signal(signal.SIGINT, signal_handler)
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if sys.version_info < (3, 0, 0):
|
|
||||||
logger.error('nhentai now only support Python 3.x')
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from __future__ import unicode_literals, print_function
|
|
||||||
import os
|
import os
|
||||||
import copy
|
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from __future__ import print_function, unicode_literals
|
|
||||||
from tabulate import tabulate
|
from tabulate import tabulate
|
||||||
from future.builtins import range
|
|
||||||
|
|
||||||
from nhentai.constant import DETAIL_URL, IMAGE_URL
|
from nhentai.constant import DETAIL_URL, IMAGE_URL
|
||||||
from nhentai.logger import logger
|
from nhentai.logger import logger
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
# coding: utf-
|
# coding: utf-
|
||||||
from __future__ import unicode_literals, print_function
|
|
||||||
|
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import signal
|
import signal
|
||||||
@ -120,14 +119,14 @@ class Downloader(Singleton):
|
|||||||
folder = os.path.join(self.path, folder)
|
folder = os.path.join(self.path, folder)
|
||||||
|
|
||||||
if not os.path.exists(folder):
|
if not os.path.exists(folder):
|
||||||
logger.warn('Path \'{0}\' does not exist, creating.'.format(folder))
|
logger.warning('Path \'{0}\' does not exist, creating.'.format(folder))
|
||||||
try:
|
try:
|
||||||
os.makedirs(folder)
|
os.makedirs(folder)
|
||||||
except EnvironmentError as e:
|
except EnvironmentError as e:
|
||||||
logger.critical('{0}'.format(str(e)))
|
logger.critical('{0}'.format(str(e)))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logger.warn('Path \'{0}\' already exist.'.format(folder))
|
logger.warning('Path \'{0}\' already exist.'.format(folder))
|
||||||
|
|
||||||
queue = [(self, url, folder) for url in queue]
|
queue = [(self, url, folder) for url in queue]
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#
|
#
|
||||||
# Copyright (C) 2010-2012 Vinay Sajip. All rights reserved. Licensed under the new BSD license.
|
# Copyright (C) 2010-2012 Vinay Sajip. All rights reserved. Licensed under the new BSD license.
|
||||||
#
|
#
|
||||||
from __future__ import print_function, unicode_literals
|
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import platform
|
import platform
|
||||||
@ -174,7 +173,7 @@ logger.setLevel(logging.DEBUG)
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
logger.log(15, 'nhentai')
|
logger.log(15, 'nhentai')
|
||||||
logger.info('info')
|
logger.info('info')
|
||||||
logger.warn('warn')
|
logger.warning('warning')
|
||||||
logger.debug('debug')
|
logger.debug('debug')
|
||||||
logger.error('error')
|
logger.error('error')
|
||||||
logger.critical('critical')
|
logger.critical('critical')
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from __future__ import unicode_literals, print_function
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@ -116,15 +115,18 @@ def doujinshi_parser(id_):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
response = request('get', url)
|
response = request('get', url)
|
||||||
if response.status_code in (200,):
|
if response.status_code in (200, ):
|
||||||
response = response.content
|
response = response.content
|
||||||
|
elif response.status_code in (404,):
|
||||||
|
logger.error("Doujinshi with id {0} cannot be found".format(id_))
|
||||||
|
return []
|
||||||
else:
|
else:
|
||||||
logger.debug('Slow down and retry ({}) ...'.format(id_))
|
logger.debug('Slow down and retry ({}) ...'.format(id_))
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
return doujinshi_parser(str(id_))
|
return doujinshi_parser(str(id_))
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warn('Error: {}, ignored'.format(str(e)))
|
logger.warning('Error: {}, ignored'.format(str(e)))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
html = BeautifulSoup(response, 'html.parser')
|
html = BeautifulSoup(response, 'html.parser')
|
||||||
@ -178,7 +180,7 @@ def old_search_parser(keyword, sorting='date', page=1):
|
|||||||
|
|
||||||
result = _get_title_and_id(response)
|
result = _get_title_and_id(response)
|
||||||
if not result:
|
if not result:
|
||||||
logger.warn('Not found anything of keyword {}'.format(keyword))
|
logger.warning('Not found anything of keyword {}'.format(keyword))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@ -219,7 +221,7 @@ def search_parser(keyword, sorting, page, is_page_all=False):
|
|||||||
break
|
break
|
||||||
|
|
||||||
if 'result' not in response:
|
if 'result' not in response:
|
||||||
logger.warn('No result in response in page {}'.format(p))
|
logger.warning('No result in response in page {}'.format(p))
|
||||||
break
|
break
|
||||||
|
|
||||||
for row in response['result']:
|
for row in response['result']:
|
||||||
@ -228,7 +230,7 @@ def search_parser(keyword, sorting, page, is_page_all=False):
|
|||||||
result.append({'id': row['id'], 'title': title})
|
result.append({'id': row['id'], 'title': title})
|
||||||
|
|
||||||
if not result:
|
if not result:
|
||||||
logger.warn('No results for keywords {}'.format(keyword))
|
logger.warning('No results for keywords {}'.format(keyword))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from __future__ import unicode_literals, print_function
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
@ -240,8 +239,11 @@ def format_filename(s):
|
|||||||
if filename include forbidden characters (\'/:,;*?"<>|) ,it replace space character(' ').
|
if filename include forbidden characters (\'/:,;*?"<>|) ,it replace space character(' ').
|
||||||
"""
|
"""
|
||||||
# maybe you can use `--format` to select a suitable filename
|
# maybe you can use `--format` to select a suitable filename
|
||||||
ban_chars = '\\\'/:,;*?"<>|'
|
ban_chars = '\\\'/:,;*?"<>|\t'
|
||||||
filename = s.translate(str.maketrans(ban_chars, ' '*len(ban_chars))).strip()
|
filename = s.translate(str.maketrans(ban_chars, ' '*len(ban_chars))).strip()
|
||||||
|
filename = ' '.join(filename.split())
|
||||||
|
print(repr(filename))
|
||||||
|
|
||||||
while filename.endswith('.'):
|
while filename.endswith('.'):
|
||||||
filename = filename[:-1]
|
filename = filename[:-1]
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user