A REST-API that provide endpoints for searching, extracting metadata and downloading YouTube videos in mp4, webm, m4a and mp3 formats in different qualities.
Follow these steps to install and configure the YouTube video downloader:
First, clone the repository using the following command:
git clone https://github.com/Simatwa/youtube-downloader-api.git
cd youtube-downloader
Next, create and activate a virtual environment:
pip install virtualenv
virtualenv venv
source venv/bin/activate
After activating the virtual environment, install the required dependencies:
pip install -r requirements.txt
Copy any of configs/env/* file to the root directory of the project and rename it to .env
. Edit the .env
file to set up your environment variables according to your needs.
Warning
Some of the settings in the .env
file are very sensitive to the app. A slight change can have a significant impact on the apps's functionality. Ensure you're in good knowledge of the changes you will be making.
Finally, start the server using the following command:
python -m fastapi run app
The docs will be accessible from http://localhost:8000/api/docs and redocs from http://localhost:8000/api/redoc
Tip
For a more smoother control over the server's startup, consider using the FastAPI's cli.
Running $ fastapi run app
will equally fire-up the server.
For more help info such as changing host and port, you can simply run $ fastapi run --help
.
In order to serve frontend contents, you have to pass directory containing the contents to the app using frontend_dir
key in the configuration file.
Note
The frontend directory should contain index.html
file.
To improve server performance and minimize load, I recommend setting up a separate server for handling static contents (audios and videos). To do this:
- Execute the
static-server
file. - Configure the API using the
static_server_url
key with the URL of the static server.
Important
It's recommened to use a uWSGI to serve the static contents at production environment. This uwsgi.sh file might come handy in this.
YouTube flags requests without proper authorization. To work around this issue:
- Use cookies and po_token as authorized workarounds.
- Alternatively, use a proxy from a location exempted from required authorizations (e.g., Canada, USA).
Note
While using a proxy is a straightforward solution, there's no guarantee that the request will go through successfully.
The following projects provide web-interfaces for interacting with Youtube-Downloader-API
Index | 🎁 Projects | ⭐ Stars |
---|---|---|
0 | y2mate-clone |
Feel free to add another web-interface to this list.
For detailed information on extracting PO Tokens, refer to the following resource: