def player(vid_pk): vid = db.getVideo(vid_pk) youtube_video = 'youtube.com' in vid['url'] if youtube_video: params = urlparse.urlparse(vid['url'])[4] match = re.match(r"(?P<yt_id>v=(\d|\w)*)", params) vid['url'] = match.group('yt_id')[2:] notes = db.getNotes(vid_pk, getUser()) sorted_notes = utils.sortNotes(notes) return view('player.html', video=vid, youtube_video=youtube_video, notes=sorted_notes)
def getNotes(vid_fk): type = request.query.get('type') share = request.query.get('share') user = getUser() if share == '1': notes = db.getUserAndSharedNotes(vid_fk, user) else: notes = db.getNotes(vid_fk, user) notes = utils.sortNotes(notes) if type == 'json': response.content_type = 'application/json' return json.dumps(notes, default=app.utils.jsonSerializer) else: return view("notes.html", notes=notes)