A lightweight, powerful video downloader powered by yt-dlp. Supports 2000+ websites including YouTube, Bilibili, TikTok, and more.
It is recommended to use a virtual environment to isolate project dependencies.
Option A — Using venv (Built-in)
# Windows (PowerShell)
python -m venv venv
.\venv\Scripts\activate
# macOS / Linux
python3 -m venv venv
source venv/bin/activateOption B — Using Conda
conda create -n tubefetch python=3.10 -y
conda activate tubefetchOnce activated, install the requirements:
pip install -r requirements.txtNote: If you need to merge high-quality video/audio (bestvideo+bestaudio), you must install ffmpeg:
- macOS:
brew install ffmpeg- Ubuntu:
sudo apt install ffmpeg- Windows: Download from ffmpeg.org or
winget install ffmpeg
# Show help
python tubefetch.py --help
# Show version
python tubefetch.py --version
# Download the first video (default)
python tubefetch.py "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
# Download the Nth video on a page
python tubefetch.py "URL" -n 2
# Specify output directory
python tubefetch.py "URL" --output-dir ~/Downloads
# Use a custom config file
python tubefetch.py "URL" --config my_config.json
# Specify quality (e.g., 720p max)
python tubefetch.py "URL" -f "bestvideo[height<=720]+bestaudio/best[height<=720]"
# Verbose mode for debugging
python tubefetch.py "URL" -v
# Run as a module
python -m tubefetch "URL"Copy config.json and customize it:
cp config.json my_config.jsonThen run:
python tubefetch.py "URL" --config my_config.json| Option | Description | Default |
|---|---|---|
playlist_item |
Index of the video to download | 1 |
format |
Quality selector (avoids AV1/HEVC by default) | bestvideo[vcodec!*=av01][vcodec!*=hev1][vcodec!*=hvc1]+bestaudio/... |
merge_output_format |
Final container format | mp4 |
outtmpl |
Filename template | %(title)s.%(ext)s |
output_dir |
Download directory | ./downloads |
write_subtitle |
Download subtitles | false |
write_thumbnail |
Download thumbnails | false |
socket_timeout |
Network timeout (seconds) | 30 |
retries |
Number of retries | 3 |
user_agent |
Custom User-Agent | "" (default) |
force_generic_extractor |
Enable generic extractor fallback | false |
cookie_file |
Path to cookies.txt (for login) | "" |
| Format | Description |
|---|---|
best |
Best single-file format |
worst |
Lowest quality |
bestvideo+bestaudio/best |
Best video + best audio merged (may use AV1/HEVC) |
bestvideo[vcodec!*=av01][vcodec!*=hev1][vcodec!*=hvc1]+bestaudio/... |
Best quality excluding AV1/HEVC (Recommended) |
bestvideo[height<=720]+bestaudio/best[height<=720] |
720p Max |
bestvideo[height<=1080]+bestaudio/best[height<=1080] |
1080p Max |
Compatibility Note: Some sites (like Bilibili) use AV1 (
av01) or HEVC (hev1/hvc1) for high-quality videos. Windows Media Player often lacks native support for these, resulting in "audio only, no picture". The default configuration filters these out to ensure H.264 (avc1) compatibility.
Some videos require login. You can provide cookies:
- Install a browser extension to export cookies:
- Chrome: Get cookies.txt LOCALLY
- Firefox: cookies.txt
- Log in to the site, click the extension, and export
cookies.txt. - Set
cookie_fileinconfig.json:"cookie_file": "/path/to/cookies.txt"
# This requires yt-dlp directly
yt-dlp --cookies-from-browser chrome "URL"Powered by yt-dlp, TubeFetch supports 2000+ sites including:
- International: YouTube, Twitter/X, Instagram, TikTok, Facebook, Vimeo, Twitch
- China: Bilibili, Douyin, Youku, iQIYI, Tencent Video, Weibo, NetEase Music
- Others: Any page with embedded video via the generic extractor.
See the full list: yt-dlp --list-extractors
- Update yt-dlp:
pip install -U yt-dlp - Enable generic extractor in config:
"force_generic_extractor": true - Provide cookies if the video is restricted.
TubeFetch supports external downloaders like aria2:
pip install aria2
python tubefetch.py "URL" # Automatically detectedusage: tubefetch.py [-h] [-n ITEM] [-o OUTPUT_DIR] [-c CONFIG] [-f FORMAT]
[-v] [-q] [--version] url
positional arguments:
url URL of the video page
options:
-h, --help show this help message and exit
-n, --item ITEM Index of the video (default: 1)
-o, --output-dir OUTPUT_DIR
Directory to save videos
-c, --config CONFIG Path to a custom JSON config file
-f, --format FORMAT Video format selector (yt-dlp syntax)
-v, --verbose Enable verbose debug output
-q, --quiet Suppress all output except errors
--version show program's version number and exit