def admin(): if request.method == "GET": videos = Video.objects() return render_template('admin.html', videos = videos) elif request.method == "POST": form = request.form link = form['link'] ydl = YoutubeDL() data = ydl.extract_info(link, download = False) title = data['title'] thumbnail = data['thumbnail'] views = data ['view_count'] youtube_id = data['id'] video = Video(title = title, thumbnail = thumbnail, views = views, youtube_id = youtube_id, link = link) video.save() return redirect(url_for("admin"))
def admin(): if 'logged_in' in session: if request.method == 'GET': all_video = Video.objects() return render_template('admin.html', all_video=all_video) elif request.method == 'POST': form = request.form link = form['link'] ydl = YoutubeDL() data = ydl.extract_info(link, download=False) new_video = Video(title=data['title'], thumbnail=data['thumbnail'], view=data['view_count'], youtubeid=data['id']) new_video.save() return redirect(url_for('admin')) else: return "Đi chỗ khác chơi"
def admin(): if request.method == 'GET': if "logged_in" in session: videos = Video.objects() return render_template('admin.html', videos=videos) else: return render_template("error.html") elif request.method == 'POST': form = request.form link = form['link'] data = ydl.extract_info(link, download=False) title = data['title'] thumbnail = data['thumbnail'] views = data['view_count'] youtubeid = data['id'] new_video = Video(title=title, thumbnail=thumbnail, views=views, link=link, youtubeid=youtubeid) new_video.save() return redirect(url_for('admin'))
def index(): all_video = Video.objects() return render_template('index.html', all_video=all_video)
def index(): videos = Video.objects() return render_template('index.html', videos=videos)