How to use the nhentai.logger.logger function in nhentai

To help you get started, we’ve selected a few nhentai examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RicterZ / nhentai / nhentai / cmdline.py View on Github external
if os.path.exists(os.path.join(constant.NHENTAI_HOME, 'cookie')):
        with open(os.path.join(constant.NHENTAI_HOME, 'cookie'), 'r') as f:
            constant.COOKIE = f.read()

    if args.cookie:
        try:
            if not os.path.exists(constant.NHENTAI_HOME):
                os.mkdir(constant.NHENTAI_HOME)

            with open(os.path.join(constant.NHENTAI_HOME, 'cookie'), 'w') as f:
                f.write(args.cookie)
        except Exception as e:
            logger.error('Cannot create NHENTAI_HOME: {}'.format(str(e)))
            exit(1)

        logger.info('Cookie saved.')
        exit(0)

    if os.path.exists(os.path.join(constant.NHENTAI_HOME, 'proxy')):
        with open(os.path.join(constant.NHENTAI_HOME, 'proxy'), 'r') as f:
            link = f.read()
            constant.PROXY = {'http': link, 'https': link}

    if args.proxy:
        try:
            if not os.path.exists(constant.NHENTAI_HOME):
                os.mkdir(constant.NHENTAI_HOME)

            proxy_url = urlparse(args.proxy)
            if proxy_url.scheme not in ('http', 'https'):
                logger.error('Invalid protocol \'{0}\' of proxy, ignored'.format(proxy_url.scheme))
            else:
github RicterZ / nhentai / nhentai / cmdline.py View on Github external
def banner():
    logger.info(u'''nHentai ver %s: あなたも変態。 いいね?
       _   _            _        _
 _ __ | | | | ___ _ __ | |_ __ _(_)
| '_ \| |_| |/ _ \ '_ \| __/ _` | |
| | | |  _  |  __/ | | | || (_| | |
|_| |_|_| |_|\___|_| |_|\__\__,_|_|
''' % __version__)
github RicterZ / nhentai / nhentai / downloader.py View on Github external
def _download(self, url, folder='', filename='', retried=0):
        if self.delay:
            time.sleep(self.delay)
        logger.info('Starting to download {0} ...'.format(url))
        filename = filename if filename else os.path.basename(urlparse(url).path)
        base_filename, extension = os.path.splitext(filename)
        try:
            if os.path.exists(os.path.join(folder, base_filename.zfill(3) + extension)):
                logger.warning('File: {0} exists, ignoring'.format(os.path.join(folder, base_filename.zfill(3) +
                                                                                extension)))
                return 1, url

            response = None
            with open(os.path.join(folder, base_filename.zfill(3) + extension), "wb") as f:
                i = 0
                while i < 10:
                    try:
                        response = request('get', url, stream=True, timeout=self.timeout)
                        if response.status_code != 200:
                            raise NhentaiImageNotExistException

                    except NhentaiImageNotExistException as e:
                        raise e

                    except Exception as e:
github RicterZ / nhentai / nhentai / downloader.py View on Github external
def _download(self, url, folder='', filename='', retried=0):
        if self.delay:
            time.sleep(self.delay)
        logger.info('Starting to download {0} ...'.format(url))
        filename = filename if filename else os.path.basename(urlparse(url).path)
        base_filename, extension = os.path.splitext(filename)
        try:
            if os.path.exists(os.path.join(folder, base_filename.zfill(3) + extension)):
                logger.warning('File: {0} exists, ignoring'.format(os.path.join(folder, base_filename.zfill(3) +
                                                                                extension)))
                return 1, url

            response = None
            with open(os.path.join(folder, base_filename.zfill(3) + extension), "wb") as f:
                i = 0
                while i < 10:
                    try:
                        response = request('get', url, stream=True, timeout=self.timeout)
                        if response.status_code != 200:
                            raise NhentaiImageNotExistException
github RicterZ / nhentai / nhentai / command.py View on Github external
data = set(db.get_all())

            doujinshi_ids = list(set(doujinshi_ids) - data)

    if doujinshi_ids:
        for i, id_ in enumerate(doujinshi_ids):
            if options.delay:
                time.sleep(options.delay)

            doujinshi_info = doujinshi_parser(id_)

            if doujinshi_info:
                doujinshi_list.append(Doujinshi(name_format=options.name_format, **doujinshi_info))

            if (i + 1) % 10 == 0:
                logger.info('Progress: %d / %d' % (i + 1, len(doujinshi_ids)))

    if not options.is_show:
        downloader = Downloader(path=options.output_dir, size=options.threads,
                                timeout=options.timeout, delay=options.delay)

        for doujinshi in doujinshi_list:

            doujinshi.downloader = downloader
            doujinshi.download()
            if options.is_save_download_history:
                with DB() as db:
                    db.add_one(doujinshi.id)

            if not options.is_nohtml and not options.is_cbz:
                generate_html(options.output_dir, doujinshi)
            elif options.is_cbz: