I am a beginner in python. I am currently building an online video study website like Udemy and Treehouse using Flask. The little issue is that, the videos on the site can be downloaded by viewing or inspecting the source code. Browsers with video download extension (firefox, Chrome etc) can easily download videos when the video page loads. The HTML and python codes are shown below
<video id="videoElementID" width="100%" oncontextmenu="return false;" controlsList="nodownload" controls>
<source src="{{ videoclip }}" id="video" type="video/mp4">
</video>
@posts.route("/<int:post_id>/<int:chapters_id>/<int:video_id>", methods=['GET','POST'])
@login_required
def view_videos(post_id, chapters_id, video_id):
posts=Post.query.get_or_404(post_id)
if posts.author != current_user:
abort(403)
chapters=C.query.get_or_404(chapters_id)
videos=V.query.get_or_404(video_id)
videoclip = url_for('static', filename='stylesheets/v_uploads/' + posts.author.username + '/' + posts.course_name + '/' + videos.video_file)
return render_template('video.html', title="view video: ", videoclip=videoclip, posts=posts, chapters = chapters, videos=videos)
This is what I want:
- to prevent browsers with file download extension from downloading the videos on the site
- to hide the video url from the source code maybe by encrypting the path or the filename or the video itself
- or more...
I have tried .htaccess but i think it only works with PHP. I tried to encrypt the code but i couldn't do it successfully. I have checked stackoverflow questions, but wasn't successful. I know its impossible to completely stop viewers from downloading but i just want to make it harder to download. Please I really need you guys to help me out. Thanks