This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import redirect, send_file | |
from io import BytesIO | |
@app.route("/download", methods = ["GET", "POST"]) | |
def download_video(): | |
if request.method == "POST": | |
buffer = BytesIO() # Declaring the buffer | |
url = YouTube(session['link']) # Getting the URL | |
itag = request.form.get("itag") # Get the video resolution | |
video = url.streams.get_by_itag(itag) # Store the video into a variable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'layout.html' %} | |
{% block content %} | |
<form method="POST" action="{{ url_for('download_video') }}"> # Linking to a Python function we'll create next | |
<h3>{{ url.title }}</h5> # The video title | |
<select name="itag" aria-label="Default select example"> | |
{% for i in url.streams.filter(progressive=True) %} | |
<option value="{{ i.itag }}"> {{ i.resolution }} </option> # Iterating through the qualities of the video. | |
{% endfor %} | |
</select> | |
<button type="submit">Download</button> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form method="POST"> | |
<input type="text" placeholder="Enter the YouTube video URL" aria-label="default input example" name="url"> | |
<button type="submit">Convert</button> | |
</form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'layout.html' %} | |
{% block content %} | |
<form method="POST"> | |
<input type="text" placeholder="Enter the YouTube video URL" aria-label="default input example" name="url"> | |
<button type="submit">Convert</button> | |
</form> | |
{% endblock content %} |