예제 #1
0
    def _save_all_chapter_db(self, comic, chapter_list):
        logger.info('_save_all_chapter_db for comic')

        for index, chapter_dict in enumerate(chapter_list, 0):
            chapter_title = list(chapter_dict.keys())[0]
            chapter_link = list(chapter_dict.values())[0]
            logger.info('{}_ -chapter-__{}'.format(chapter_title,
                                                   chapter_link))
            chapter_obj = Chapter.normal.filter(book=comic,
                                                book_type=BOOK_TYPE_DESC.Comic,
                                                title=chapter_title).first()
            if not chapter_obj:
                chapter_obj = Chapter()
            chapter_obj.comic = comic
            chapter_obj.title = chapter_title
            chapter_obj.order = index
            chapter_obj.origin_addr = chapter_link
            chapter_obj.save()
예제 #2
0
    def _save_all_chapter_db(self, book, chapter_list):
        logger.info('_save_all_chapter_db')

        for index, chapter_dict in enumerate(chapter_list, 0):
            chapter_title = list(chapter_dict.keys())[0]
            chapter_link = list(chapter_dict.values())[0]
            logger.info('{}_ -chapter-__{}'.format(chapter_title,
                                                   chapter_link))

            chapter_obj = Chapter.normal.filter(book=book,
                                                title=chapter_title).first()
            if not chapter_obj:
                chapter_obj = Chapter()
            chapter_obj.book = book
            chapter_obj.title = chapter_title
            chapter_obj.order = index
            chapter_obj.origin_addr = chapter_link
            chapter_obj.save()