Skip to content

A REST-API that provide endpoints for searching, extracting metadata and downloading YouTube videos in mp4, webm, m4a and mp3 formats in different qualities including 8k.

License

Notifications You must be signed in to change notification settings

Simatwa/youtube-downloader-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YouTube Video Downloader API

License Latest release release date Black

Overview

A REST-API that provide endpoints for searching, extracting metadata and downloading YouTube videos in mp4, webm, m4a and mp3 formats in different qualities.

Prerequisites

Installation Guide

Follow these steps to install and configure the YouTube video downloader:

Step 1: Clone Repository

First, clone the repository using the following command:

git clone https://github.com/Simatwa/youtube-downloader-api.git
cd youtube-downloader

Step 2: Set Up Virtual Environment

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

Step 3: Configure Environment Variables

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.

Step 4: Start the Server

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.

Serving frontend contents

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.

Optimizing Server Performance

To improve server performance and minimize load, I recommend setting up a separate server for handling static contents (audios and videos). To do this:

  1. Execute the static-server file.
  2. 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.

Troubleshooting

Authorization Issues

YouTube flags requests without proper authorization. To work around this issue:

  1. Use cookies and po_token as authorized workarounds.
  2. 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.

Utility Servers

  1. Static Server
  2. Proxy Server

Web-Interfaces

The following projects provide web-interfaces for interacting with Youtube-Downloader-API

Index 🎁 Projects ⭐ Stars
0 y2mate-clone Stars

Feel free to add another web-interface to this list.

Additional Resources

For detailed information on extracting PO Tokens, refer to the following resource:

How to extract PO Token

License

About

A REST-API that provide endpoints for searching, extracting metadata and downloading YouTube videos in mp4, webm, m4a and mp3 formats in different qualities including 8k.

Topics

Resources

License

Stars

Watchers

Forks