Exemplo n.º 1
0
    def set_info(self, info):
        self.info.update(info)
        if self.kind == Type.csdnblog_author:
            self.epub.title = u'csdn博客作者_{}({})文章集锦'.format(info['creator_name'], info['creator_id'])
            self.epub.id = info['creator_id']
        elif self.kind == Type.cnblogs_author:
            self.epub.title = u'cnblogs作者_{}({})文章集锦'.format(info['creator_name'], info['creator_id'])
            self.epub.id = info['creator_id']
        elif self.kind == Type.jianshu_author:              # 该博客所有的博文
            self.epub.title = u'简书作者_{}({})文章集锦'.format(info['creator_name'], info['creator_id'])
            self.epub.id = info['creator_id']
        elif self.kind == Type.jianshu_collection:
            self.epub.title = u'简书专题_{}({})'.format(info['title'], info['collection_fake_id'])
            self.epub.id = info['collection_fake_id']
        elif self.kind == Type.jianshu_notebooks:
            self.epub.title = u'简书文集_{}({})'.format(info['title'], info['notebooks_id'])
            self.epub.id = info['notebooks_id']
        elif self.kind == Type.jianshu_article:    # 单篇博文 TODO
            self.epub.title = u'简书博文集锦({})'.format(info['title'])
            self.epub.id = info['id']       # TODO
        elif self.kind == Type.sinablog_author:              # 该博客所有的博文
            self.epub.title = u'新浪博客_{}({})'.format(info['creator_name'], info['creator_id'])
            self.epub.id = info['creator_id']
        elif self.kind == Type.sinablog_article:    # 新浪单篇博文 TODO
            self.epub.title = u'新浪博客博文集锦({})'.format(info['title'])
            self.epub.id = info['id']       # TODO
        elif self.kind == Type.question:
            self.epub.title = u'知乎问题集锦({})'.format(info['title'])
            self.epub.id = info['id']
        elif self.kind == Type.answer:
            self.epub.title = u'知乎回答集锦({})'.format(info['title'])
            self.epub.id = info['id']
        elif self.kind == Type.article:
            self.epub.title = u'知乎专栏文章集锦({})'.format(info['title'])
            self.epub.id = info['id']
        elif self.kind == Type.topic:
            self.epub.title = u'知乎话题_{}({})'.format(info['title'], info['topic_id'])
            self.epub.id = info['topic_id']
        elif self.kind == Type.collection:
            self.epub.title = u'知乎收藏夹_{}({})'.format(info['title'], info['collection_id'])
            self.epub.id = info['collection_id']
        elif self.kind == Type.author:
            self.epub.title = u'知乎作者_{}({})'.format(info['name'], info['author_id'])
            self.epub.id = info['author_id']
        elif self.kind == Type.column:
            self.epub.title = u'知乎专栏_{}({})'.format(info['name'], info['column_id'])
            self.epub.id = info['column_id']
        elif self.kind == Type.yiibai:
            self.epub.title = u'易百教程_{}'.format(info['title'])
            self.epub.id = info['creator_id']
        elif self.kind == Type.talkpython:
            self.epub.title = u'TalkPythonToMe'
            self.epub.id = info['creator_id']

        from src.html5lib.constants import entities_reverse
        self.epub.title = Match.replace_words(self.epub.title, entities_reverse)
        return