A simple web application to fetch and download YouTube video information using Quart and PyTube.
- Fetch YouTube video title
- Fetch the highest resolution video stream URL
- Fetch video thumbnail URL
- Python 3.7+
- Quart
- PyTube
-
Clone the repository:
git clone https://github.com/lalsproject/python_yt_downloader.git cd python_yt_downloader -
Create a virtual environment:
python3 -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the dependencies:
pip install -r requirements.txt
-
Run the application:
python main.py
-
Open your web browser and go to
http://0.0.0.0:5000/. -
Use the form to input a YouTube video URL and fetch its information.
- The application uses the Quart framework to create an asynchronous web server.
- The root route (
'/') renders theindex.htmltemplate. - The
/downloadroute accepts POST requests with a YouTube video URL, fetches the video information using PyTube, and returns the data in JSON format.
Fetches information for a given YouTube video URL:
video_url: The URL of the YouTube video.- Returns a dictionary containing the video title, highest resolution stream URL, and thumbnail URL.
Handles POST requests to the /download route:
- Extracts the video URL from the form data.
- Calls
fetch_video_info(video_url)to fetch the video information. - Returns the information as a JSON response.
Here is an example of how to use the application:
- Open the application in your web browser.
- Enter a YouTube video URL in the input field and submit the form.
- The application will return a JSON response with the video title, URL of the highest resolution stream, and thumbnail URL.
This project is licensed under the MIT License. See the LICENSE file for more details.