示例#1
0
文件: api.py 项目: kgov1/pytaku
    def get(self):
        chapter = create_or_get_chapter(self.data['url'])

        resp = {
            'name': chapter.name,
            'url': chapter.url,
            'pages': chapter.pages,
            'series_url': chapter.series_url,
            'series_name': chapter.series_name,
            'next_chapter_url': chapter.next_chapter_url,
            'prev_chapter_url': chapter.prev_chapter_url,
        }

        if hasattr(self, 'user'):
            user = self.user
            resp['is_bookmarked'] = chapter.is_bookmarked(user)
            resp['progress'] = self.user.chapter_progress(resp['url'])

        # Fetch next chapter in background
        next_url = resp['next_chapter_url']
        if next_url is not None:
            taskqueue.add(queue_name='fetch-chapter',
                          url='/workers/fetch-chapter',
                          params={'url': next_url})
        return resp
示例#2
0
文件: api.py 项目: PythonPaper/pytaku
    def get(self):
        chapter = create_or_get_chapter(self.data['url'])

        resp = {
            'name': chapter.name,
            'url': chapter.url,
            'pages': chapter.pages,
            'series_url': chapter.series_url,
            'series_name': chapter.series_name,
            'next_chapter_url': chapter.next_chapter_url,
            'prev_chapter_url': chapter.prev_chapter_url,
        }

        if hasattr(self, 'user'):
            user = self.user
            resp['is_bookmarked'] = chapter.is_bookmarked(user)
            resp['progress'] = self.user.chapter_progress(resp['url'])

        # Fetch next chapter in background
        next_url = resp['next_chapter_url']
        if next_url is not None:
            taskqueue.add(queue_name='fetch-chapter',
                          url='/workers/fetch-chapter',
                          params={'url': next_url})
        return resp
示例#3
0
文件: api.py 项目: PythonPaper/pytaku
 def get(self):
     chapters = [create_or_get_chapter(url)
                 for url in self.user.bookmarked_chapters]
     return [{
         'series_url': chapter.series_url,
         'series_name': chapter.series_name,
         'name': chapter.name,
         'url': chapter.url,
     } for chapter in chapters]
示例#4
0
文件: api.py 项目: kgov1/pytaku
 def get(self):
     chapters = [
         create_or_get_chapter(url) for url in self.user.bookmarked_chapters
     ]
     return [{
         'series_url': chapter.series_url,
         'series_name': chapter.series_name,
         'name': chapter.name,
         'url': chapter.url,
     } for chapter in chapters]
示例#5
0
文件: routes.py 项目: hnq90/pytaku
 def get(self, query=None):
     url = unquote(query)
     chapter = create_or_get_chapter(url)
     series = create_or_get_series(chapter.series_url)
     template = jinja.get_template('series.html')
     self.response.write(template.render({
         'title': '%s - %s' % (chapter.name, chapter.series_name),
         'thumb_url': chapter.pages[0],
         'descriptions': series.description if series.description else [],
     }))
示例#6
0
 def get(self, query=None):
     url = unquote(query)
     chapter = create_or_get_chapter(url)
     series = create_or_get_series(chapter.series_url)
     template = jinja.get_template('series.html')
     self.response.write(
         template.render({
             'title':
             '%s - %s' % (chapter.name, chapter.series_name),
             'thumb_url':
             chapter.pages[0],
             'descriptions':
             series.description if series.description else [],
         }))
示例#7
0
文件: api.py 项目: NamPNQ/pytaku
    def get(self):
        chapter = create_or_get_chapter(self.data['url'])

        resp = {
            'name': chapter.name,
            'url': chapter.url,
            'pages': chapter.pages,
            'series_url': chapter.series_url,
            'series_name': chapter.series_name,
            'next_chapter_url': chapter.next_chapter_url,
            'prev_chapter_url': chapter.prev_chapter_url,
        }

        if hasattr(self, 'user'):
            user = self.user
            resp['is_bookmarked'] = chapter.is_bookmarked(user)
            resp['progress'] = self.user.chapter_progress(resp['url'])

        return resp
示例#8
0
文件: workers.py 项目: kgov1/pytaku
 def post(self):
     url = self.request.get('url')
     create_or_get_chapter(url)