예제 #1
0
    def dump(self):
        filename = get_filename(self.title, self.author, self.overwrite)
        print(filename)

        with open(filename, 'w') as fp:
            fp.write(self.title)
            fp.write('\n\n')
            fp.write(self.author)

            fp.write('\n\n\n')
            if self.cache:
                novel = self.session.query(Serial).filter_by(
                    id=self.tid, source=self.source).one()
                fp.write(novel.intro)
                for ch in novel.chapters:
                    fp.write('\n\n\n\n')
                    fp.write(ch.title)
                    fp.write('\n\n\n')
                    fp.write(ch.text)
                    fp.write('\n')
            else:
                fp.write(self.get_intro())
                for _, url, title in self.chapter_list:
                    fp.write('\n\n\n\n')
                    fp.write(title)
                    fp.write('\n\n\n')
                    fp.write(self._get_chapter(url, title))
                    fp.write('\n')
예제 #2
0
 def dump(self):
     filename = get_filename(self.title, overwrite=self.overwrite)
     content = self.content
     with open(filename, 'w') as fp:
         fp.write(self.title)
         fp.write('\n\n\n\n')
         fp.write(content)
         fp.write('\n')
예제 #3
0
 def dump(self):
     filename = utils.get_filename(self.title, overwrite=self.overwrite)
     filename = filename.replace('/', '_')
     print(filename)
     if self.cache:
         content = self.session.query(models.Article).filter_by(
             id=self.tid, source=self.source).one().text
     else:
         content = self.content
     with open(filename, 'w') as fp:
         fp.write(content)
예제 #4
0
 def dump(self):
     filename = get_filename(self.title, overwrite=self.overwrite)
     print(filename)
     if self.cache:
         content = self.session.query(Article).filter_by(
             id=self.tid, source=self.source).one().text
     else:
         content = self.content
     with open(filename, 'w') as fp:
         fp.write(self.title)
         fp.write('\n\n\n\n')
         fp.write(content)
         fp.write('\n')
예제 #5
0
    def dump_article(self, source, tid):
        novel = self.session.query(Article).filter_by(source=source,
                                                      id=tid).one()
        if source in sources.DEFAULT_NOT_OVERWRITE:
            overwrite = False
        else:
            overwrite = True
        filename = get_filename(novel.title, overwrite=overwrite)
        print(filename)

        with open(filename, 'w') as fp:
            fp.write(novel.title)
            fp.write('\n\n\n\n')
            fp.write(novel.text)
            fp.write('\n')
예제 #6
0
 def dump(self, path=None, folder=None, num=None):
     if not path:
         if num is not None:
             pre = '「{:d}」'.format(num)
         else:
             pre = ''
         filename = '{}{}'.format(
             pre, get_filename(self.title, overwrite=self.overwrite))
         if not folder:
             path = os.path.join(os.getcwd(), filename)
         else:
             path = os.path.join(folder, filename)
     print((self.title))
     with open(path, 'w') as fp:
         fp.write(self.title)
         fp.write('\n\n\n')
         fp.write(self.content)
         fp.write('\n')
예제 #7
0
    def dump_serial(self, source, tid):
        novel = self.session.query(Serial).filter_by(source=source,
                                                     id=tid).one()
        if source in sources.DEFAULT_NOT_OVERWRITE:
            overwrite = False
        else:
            overwrite = True
        filename = get_filename(novel.title, novel.author, overwrite=overwrite)
        print(filename)

        with open(filename, 'w') as fp:
            fp.write(novel.title)
            fp.write('\n\n')
            fp.write(novel.author)
            fp.write('\n\n\n')
            fp.write(novel.intro)
            for ch in novel.chapters:
                fp.write('\n\n\n\n')
                fp.write(ch.title)
                fp.write('\n\n\n')
                fp.write(ch.text)
                fp.write('\n')