A simple Python command-line video downloader built with yt-dlp.
The script accepts a video URL, downloads the best available video and audio, attempts to merge them into an MP4 file, displays download progress, and can automatically open the downloaded video using your system's default media player.
- Download videos using
yt-dlp - Supports websites supported by
yt-dlp - Downloads the best available video and audio
- Automatically merges video and audio into MP4 when necessary
- Live download progress display
- Automatically creates the output directory
- Optional automatic video playback after downloading
- Works on Windows, macOS, and Linux
- Simple command-line interface
- Python 3.8+
yt-dlp- FFmpeg
Check that Python is installed:
python --versionor:
python3 --versionpip install yt-dlpIf your system uses pip3:
pip3 install yt-dlpFFmpeg is recommended because some websites provide video and audio as separate streams. yt-dlp needs FFmpeg to merge them into a single video file.
Check whether FFmpeg is installed:
ffmpeg -versionIf the command is not found, install FFmpeg for your operating system and make sure it is available in your system PATH.
Clone the repository:
git clone https://github.com/ben041/yt5downloader.gitEnter the project directory:
cd yt5downloaderInstall the Python dependency:
pip install yt-dlpYou can also install the dependencies from a requirements.txt file if one is included in the project:
pip install -r requirements.txtRun the script:
python downloader.pyOn some systems:
python3 downloader.pyThe program will ask for two values:
enter video link / url(tiktok , facebook, youtube):
enter output name (without extension):
enter video link / url(tiktok , facebook, youtube): https://example.com/video
enter output name (without extension): my_video
The downloaded file will be saved using the name:
my_video.mp4
The script displays download progress in the terminal:
[#########################-------------------------] 50.00% - Speed: 2.35 MB/s
After the download finishes:
Download completed!!
Video downloaded successfully: ./my_video.mp4
If autoplay is enabled, the downloaded video will then be opened automatically.
The script has three main parts.
The play_video() function detects the operating system and attempts to open the downloaded video.
- Windows: uses
os.startfile() - macOS: uses
open - Linux/Unix: looks for
xdg-open,vlc, ormpv
The download_video() function uses yt-dlp to:
- Create the output directory if it doesn't exist.
- Configure the output filename.
- Select the best available video/audio combination.
- Download the media.
- Merge the streams into MP4 when required.
- Display download progress.
- Optionally open the downloaded file.
The hook() function receives progress information from yt-dlp and displays:
- Download percentage
- Download speed
- A progress bar
- Completion status
The downloader can also be imported into another Python program:
from downloader import download_video
result = download_video(
"https://example.com/video",
output_name="my_video",
output_dir="downloads",
autoplay=False
)
print(result["title"])
print(result["filepath"])The function returns a dictionary containing information about the downloaded video:
{
"title": "...",
"ext": "mp4",
"filepath": "/path/to/video.mp4"
}Replace
downloaderwith the actual Python filename containing the functions.
This project uses yt-dlp, which supports a large number of websites and services.
However, website support can change over time. A URL working today does not guarantee that it will continue to work if the website changes its video delivery system or access requirements.
For the current list of supported sites, see the official yt-dlp documentation:
https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md
Install it with:
pip install yt-dlpThen try running the script again.
Install FFmpeg and make sure the ffmpeg command works from your terminal:
ffmpeg -versionFirst update yt-dlp:
pip install -U yt-dlpThen try again.
Website changes, login requirements, geo-restrictions, age restrictions, or other access restrictions can prevent a download.
The script depends on a media player being available on your system.
On Linux, it checks for:
xdg-open
vlc
mpv
You can still open the downloaded file manually if no compatible player is detected.
A simple project structure can look like this:
yt5downloaderlink/
│
├── downloader.py
├── README.md
└── requirements.txt
Your actual Python filename can be different.
The main Python dependency is:
The project may also require:
This software is provided as a technical tool for downloading online media.
Users are responsible for complying with:
- Copyright laws
- The terms of service of the websites they use
- Applicable local laws and regulations
- Any restrictions associated with the content they download
Only download content that you have permission or legal rights to download.
The project does not grant users permission to download copyrighted material.
This project is not affiliated with YouTube, TikTok, Facebook, or any other website supported by yt-dlp.
Third-party websites may change their systems at any time, which can cause downloading to stop working until yt-dlp is updated.
Contributions are welcome.
If you find a bug or have an idea for improving the project:
- Fork the repository.
- Create a new branch.
- Make your changes.
- Test the changes.
- Open a pull request.
For bugs, please include:
- Operating system
- Python version
yt-dlpversion- FFmpeg version
- The error message
- Steps to reproduce the problem
Avoid posting private URLs, authentication tokens, cookies, or other sensitive information in issues.
MIT License
Made with Python and yt-dlp.