(self, request, username)
return JsonResponse({"chapters": chapters_json, "timestamp": now_})
Get chapters for an episode
Get chapters for an episode
Get chapters for an episode
def get(self, request, username):
        """Get chapters for an episode"""
        user = request.user
        now_ = get_timestamp(datetime.utcnow())

        podcast_url, episode_url, _update_urls = self.get_urls(request)

        episode = Episode.objects.filter(
            podcast__urls__url=podcast_url, urls__url=episode_url
        ).get()

        chapters = Chapter.objects.filter(user=user, episode=episode)

        since = self.get_since(request)
        if since:
            chapters = chapters.filter(created__gte=since)

        chapters_json = map(self.chapter_to_json, chapters)

        return JsonResponse({"chapters": chapters_json, "timestamp": now_})
def get ( self , request , username ) : user = request . user now_ = get_timestamp ( datetime . utcnow ( ) ) podcast_url , episode_url , _update_urls = self . get_urls ( request ) episode = Episode . objects . filter ( podcast__urls__url = podcast_url , urls__url = episode_url ) . get ( ) chapters = Chapter . objects . filter ( user = user , episode = episode ) since = self . get_since ( request ) if since : chapters = chapters . filter ( created__gte = since ) chapters_json = map ( self . chapter_to_json , chapters ) return JsonResponse ( { "chapters" : chapters_json , "timestamp" : now_ } )