def create_book(self, command, counter): Path.reset_path() Debug.logger.info(u"开始制作第 {} 本电子书".format(counter)) Debug.logger.info(u"对记录 {} 进行分析".format(command)) task_list = CommandParser.get_task_list(command) # 分析命令 if len(task_list) == 0: return for task in task_list: if Config.debug_for_create_book: pass else: Worker.distribute(task) Debug.logger.info(u"网页信息抓取完毕") task_result_list = [] for task in task_list: task_result = TaskResult(task) task_result.extract_data() task_result_list.append(task_result) Debug.logger.info(u"数据库信息获取完毕") # 下载图片 for task_result in task_result_list: task_result.download_img() Debug.logger.info(u"所有任务图片获取完毕") # 按体积自动分卷 # 渲染html && 压缩为电子书 book = Book(task_result_list) book_list = book.auto_split(Config.max_book_size_mb * 1024) for chapter in book_list: chapter.create_book() return
def merge_article_book_list(self): book_list = self.book_list[Type.article] book = Book() answer = [] for item in book_list: answer.append(item.sql.answer) book.kind = Type.article book.sql.answer = 'select * from Article where ({})'.format(' or '.join(answer)) self.book_list[Type.article] = [book] return
def merge_question_book_list(self): book_list = self.book_list[Type.question] book = Book() question = [] answer = [] for item in book_list: question.append(item.sql.question) answer.append(item.sql.answer) book.kind = Type.question book.sql.question = 'select * from Question where ({})'.format(' or '.join(question)) book.sql.answer = 'select * from Answer where ({})'.format(' or '.join(answer)) self.book_list[Type.question] = [book] return
def create_book(self, command, counter): Path.reset_path() Debug.logger.info(u"开始制作第 {} 本电子书".format(counter)) Debug.logger.info(u"对记录 {} 进行分析".format(command)) task_list = CommandParser.get_task_list(command) # 分析命令 if len(task_list) == 0: return for task in task_list: if Config.debug_for_create_book: pass else: Worker.distribute(task) Debug.logger.info(u"网页信息抓取完毕") task_result_list = [] toTo_list = [ Type.wechat, Type.huxiu, Type.huawei, Type.xueqiu, Type.sina, Type.zhengshitang, Type.jinwankansa, Type.wuxia, Type.doc360, Type.todo, Type.todo1, Type.todo2, Type.fiel, Type.taoguba_article ] for task in task_list: if task.get_task_type() in toTo_list: task = ColumnTask(task.account_id) task_result = TaskResult(task) task_result.extract_data() task_result_list.append(task_result) Debug.logger.info(u"数据库信息获取完毕") # 下载图片 for task_result in task_result_list: task_result.download_img() # print '所有任务图片获取完毕' Debug.logger.info(u"所有任务图片获取完毕") # 按体积自动分卷 # 渲染html && 压缩为电子书 book = Book(task_result_list) book_list = book.auto_split(Config.max_book_size_mb * 1024) for chapter in book_list: chapter.create_book() return