mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-04-20 02:41:19 +02:00
忘记干啥了..
This commit is contained in:
parent
3eacd118ed
commit
0d185f465d
@ -23,10 +23,12 @@ def banner():
|
||||
def cmd_parser():
|
||||
parser = OptionParser()
|
||||
parser.add_option('--download', dest='is_download', action='store_true', help='download doujinshi or not')
|
||||
parser.add_option('--show-info', dest='is_show', action='store_true', help='just show the doujinshi information.')
|
||||
parser.add_option('--id', type='str', dest='id', action='store', help='doujinshi ids set, e.g. 1,2,3')
|
||||
parser.add_option('--search', type='string', dest='keyword', action='store', help='keyword searched')
|
||||
parser.add_option('--search', type='string', dest='keyword', action='store', help='search doujinshi by keyword')
|
||||
parser.add_option('--page', type='int', dest='page', action='store', default=1,
|
||||
help='page number of search result')
|
||||
parser.add_option('--tags', type='string', dest='tags', action='store', help='download doujinshi by tags')
|
||||
parser.add_option('--output', type='string', dest='output_dir', action='store', default='',
|
||||
help='output dir')
|
||||
parser.add_option('--threads', '-t', type='int', dest='threads', action='store', default=5,
|
||||
@ -37,11 +39,15 @@ def cmd_parser():
|
||||
help='use proxy, example: http://127.0.0.1:1080')
|
||||
args, _ = parser.parse_args()
|
||||
|
||||
if args.tags:
|
||||
logger.warning('`--tags` is under construction')
|
||||
exit(0)
|
||||
|
||||
if args.id:
|
||||
_ = map(lambda id: id.strip(), args.id.split(','))
|
||||
args.id = set(map(int, filter(lambda id: id.isdigit(), _)))
|
||||
|
||||
if args.is_download and not args.id and not args.keyword:
|
||||
if (args.is_download or args.is_show) and not args.id and not args.keyword:
|
||||
logger.critical('Doujinshi id(s) are required for downloading')
|
||||
parser.print_help()
|
||||
exit(0)
|
||||
|
@ -31,14 +31,19 @@ def main():
|
||||
else:
|
||||
exit(0)
|
||||
|
||||
if not options.is_show:
|
||||
downloader = Downloader(path=options.output_dir,
|
||||
thread=options.threads, timeout=options.timeout)
|
||||
|
||||
for doujinshi in doujinshi_list:
|
||||
doujinshi.downloader = downloader
|
||||
doujinshi.download()
|
||||
|
||||
logger.log(15, u'🍺 All done.')
|
||||
|
||||
else:
|
||||
[doujinshi.show() for doujinshi in doujinshi_list]
|
||||
|
||||
|
||||
def signal_handler(signal, frame):
|
||||
logger.error('Ctrl-C signal received. Quit.')
|
||||
|
@ -1,10 +1,9 @@
|
||||
import os
|
||||
|
||||
SCHEMA = os.getenv('NHENTAI_SCHEMA', 'https://')
|
||||
BASE_URL = os.getenv('NHENTAI', 'nhentai.net')
|
||||
BASE_URL = os.getenv('NHENTAI', 'https://nhentai.net')
|
||||
|
||||
DETAIL_URL = '%s/g' % BASE_URL
|
||||
SEARCH_URL = '%s/search/' % BASE_URL
|
||||
IMAGE_URL = 'https://i.%s/galleries' % BASE_URL
|
||||
|
||||
URL = '%s%s' % (SCHEMA, BASE_URL)
|
||||
DETAIL_URL = '%s/g' % URL
|
||||
SEARCH_URL = '%s/search/' % URL
|
||||
IMAGE_URL = '%si.%s/galleries' % (SCHEMA, BASE_URL)
|
||||
PROXY = {}
|
||||
|
@ -43,7 +43,7 @@ class Doujinshi(object):
|
||||
["URL", self.url],
|
||||
["Pages", self.pages],
|
||||
]
|
||||
logger.info(u'Print doujinshi information\n{0}'.format(tabulate(table)))
|
||||
logger.info(u'Print doujinshi information of {0}\n{1}'.format(self.id, tabulate(table)))
|
||||
|
||||
def download(self):
|
||||
logger.info('Start download doujinshi: %s' % self.name)
|
||||
|
@ -1,10 +1,14 @@
|
||||
# coding: utf-8
|
||||
|
||||
|
||||
class _Singleton(type):
|
||||
""" A metaclass that creates a Singleton base class when called. """
|
||||
_instances = {}
|
||||
|
||||
def __call__(cls, *args, **kwargs):
|
||||
if cls not in cls._instances:
|
||||
cls._instances[cls] = super(_Singleton, cls).__call__(*args, **kwargs)
|
||||
return cls._instances[cls]
|
||||
|
||||
|
||||
class Singleton(_Singleton('SingletonMeta', (object,), {})): pass
|
Loading…
x
Reference in New Issue
Block a user