def main(): banner() logger.info('Using mirror: {0}'.format(BASE_URL)) options = cmd_parser() doujinshi_ids = [] doujinshi_list = [] if options.login: username, password = options.login.split(':', 1) logger.info('Logging in to nhentai using credential pair \'%s:%s\'' % (username, '*' * len(password))) login(username, password) if options.is_download: for doujinshi_info in login_parser(): doujinshi_list.append(Doujinshi(**doujinshi_info)) if options.tag: doujinshis = tag_parser(options.tag, max_page=options.max_page) print_doujinshi(doujinshis) if options.is_download: doujinshi_ids = map(lambda d: d['id'], doujinshis) if options.keyword: doujinshis = search_parser(options.keyword, options.page) print_doujinshi(doujinshis) if options.is_download: doujinshi_ids = map(lambda d: d['id'], doujinshis) if not doujinshi_ids: doujinshi_ids = options.id if doujinshi_ids: for id_ in doujinshi_ids: doujinshi_info = doujinshi_parser(id_) doujinshi_list.append(Doujinshi(**doujinshi_info)) 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() if not options.is_nohtml and not options.is_cbz: generate_html(options.output_dir, doujinshi) elif options.is_cbz: generate_cbz(options.output_dir, doujinshi, options.rm_origin_dir) if not platform.system() == 'Windows': logger.log(15, '🍻 All done.') else: logger.log(15, 'All done.') else: [doujinshi.show() for doujinshi in doujinshi_list]
def main(): banner() logger.info('Using mirror: {0}'.format(BASE_URL)) options = cmd_parser() doujinshi_ids = [] doujinshi_list = [] if options.favorites: if not options.is_download: logger.warning('You do not specify --download option') doujinshi_ids = favorites_parser() elif options.tag: doujinshis = tag_parser(options.tag, max_page=options.max_page) print_doujinshi(doujinshis) if options.is_download and doujinshis: doujinshi_ids = map(lambda d: d['id'], doujinshis) elif options.keyword: doujinshis = search_parser(options.keyword, options.page) print_doujinshi(doujinshis) if options.is_download: doujinshi_ids = map(lambda d: d['id'], doujinshis) elif not doujinshi_ids: doujinshi_ids = options.id if doujinshi_ids: for id_ in doujinshi_ids: if options.delay: time.sleep(options.delay) doujinshi_info = doujinshi_parser(id_) doujinshi_list.append(Doujinshi(name_format=options.name_format, path=options.output_dir, **doujinshi_info)) if not options.is_show: downloader = Downloader(path=options.output_dir, thread=options.threads, timeout=options.timeout, delay=options.delay) for doujinshi in doujinshi_list: doujinshi.downloader = downloader doujinshi.download() if not options.is_nohtml and not options.is_cbz: generate_html(options.output_dir, doujinshi) elif options.is_cbz: generate_cbz(options.output_dir, doujinshi, options.rm_origin_dir) if not platform.system() == 'Windows': logger.log(15, '🍻 All done.') else: logger.log(15, 'All done.') else: [doujinshi.show() for doujinshi in doujinshi_list]
def main(): banner() options = cmd_parser() logger.info('Using mirror: {0}'.format(BASE_URL)) from nhentai.constant import PROXY # constant.PROXY will be changed after cmd_parser() if PROXY != {}: logger.info('Using proxy: {0}'.format(PROXY)) # check your cookie check_cookie() index = 0 index_value = None doujinshis = [] doujinshi_ids = [] doujinshi_list = [] if options.favorites: if not options.is_download: logger.warning('You do not specify --download option') doujinshis = favorites_parser(options.page_range) elif options.tag: doujinshis = tag_parser(options.tag, sorting=options.sorting, max_page=options.max_page) elif options.artist: index = 1 index_value = options.artist elif options.character: index = 2 index_value = options.character elif options.parody: index = 3 index_value = options.parody elif options.group: index = 4 index_value = options.group elif options.language: index = 5 index_value = options.language elif options.keyword: doujinshis = search_parser(options.keyword, sorting=options.sorting, page=options.page) elif not doujinshi_ids: doujinshi_ids = options.id if index: doujinshis = tag_parser(index_value, max_page=options.max_page, index=index) print_doujinshi(doujinshis) if options.is_download and doujinshis: doujinshi_ids = [i['id'] for i in doujinshis] if options.is_save_download_history: with DB() as db: 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: generate_cbz(options.output_dir, doujinshi, options.rm_origin_dir, options.write_comic_info) if options.main_viewer: generate_main_html(options.output_dir) if not platform.system() == 'Windows': logger.log(15, '🍻 All done.') else: logger.log(15, 'All done.') else: [doujinshi.show() for doujinshi in doujinshi_list]