Fast and simple YouTube thumbnail extractor
Project description
yt-thumbs
YouTube thumbnail extractor. Zero dependencies.
Features
- Extract thumbnail URLs from YouTube videos
- Download thumbnails in highest available quality
- Automatically falls back from maxresdefault (1280x720) to hqdefault if unavailable
- Zero external dependencies (uses only Python standard library)
- Lightning-fast performance
- Support for all common YouTube URL formats
Installation
Using UV Tool (Recommended)
Install as a UV tool for global access:
uv tool install yt-thumbs
Or install from source:
git clone https://github.com/yourusername/yt-thumbs.git
cd yt-thumbs
uv tool install .
Using pip
pip install yt-thumbs
Usage
Get Thumbnail URL (Default)
Simply print the thumbnail URL to stdout:
yt-thumbs https://www.youtube.com/watch?v=dQw4w9WgXcQ
Output:
https://img.youtube.com/vi/dQw4w9WgXcQ/maxresdefault.jpg
Download Thumbnail
Download the thumbnail image to disk:
yt-thumbs https://www.youtube.com/watch?v=dQw4w9WgXcQ --download
This saves the thumbnail as dQw4w9WgXcQ.jpg in the current directory.
Custom Output Filename
Specify a custom filename for the downloaded thumbnail:
yt-thumbs https://www.youtube.com/watch?v=dQw4w9WgXcQ --download --output my-thumbnail.jpg
Supported URL Formats
All common YouTube URL formats are supported:
# Standard watch URL
yt-thumbs https://www.youtube.com/watch?v=dQw4w9WgXcQ
# Short URL
yt-thumbs https://youtu.be/dQw4w9WgXcQ
# Embed URL
yt-thumbs https://www.youtube.com/embed/dQw4w9WgXcQ
# URLs without protocol (http/https)
yt-thumbs youtube.com/watch?v=dQw4w9WgXcQ
CLI Options
usage: yt-thumbs [-h] [--download] [--output OUTPUT] url
Extract YouTube thumbnail URLs and download thumbnails
positional arguments:
url YouTube video URL
options:
-h, --help show this help message
--download, -d Download the thumbnail instead of printing URL
--output OUTPUT, -o OUTPUT
Output filename (default: {video_id}.jpg)
Batch Mode
Process multiple URLs and get a markdown table with video metadata:
# Create a file with URLs (one per line)
cat > urls.txt <<EOF
https://www.youtube.com/watch?v=dQw4w9WgXcQ
https://youtu.be/wiTbtugbhgw
EOF
# Process all URLs and output markdown table
yt-thumbs --batch urls.txt
# Or save to a file
yt-thumbs --batch urls.txt --output results.md
Output format:
| Thumbnail URL | Video Name | Video Description |
|---------------|------------|-------------------|
| https://img.youtube.com/vi/dQw4w9WgXcQ/maxresdefault.jpg | Rick Astley - Never Gonna Give You Up | The official video for "Never Gonna Give You Up"... |
Examples
Piping URL to clipboard (macOS)
yt-thumbs https://youtu.be/dQw4w9WgXcQ | pbcopy
Batch download multiple thumbnails
cat video_urls.txt | while read url; do
yt-thumbs "$url" --download
done
Download with custom naming
yt-thumbs https://youtu.be/dQw4w9WgXcQ --download --output thumbnails/rick-roll.jpg
How It Works
YouTube provides thumbnail images at predictable URLs based on the video ID. This tool:
- Extracts the video ID from any YouTube URL format
- Constructs the thumbnail URL (tries maxresdefault first)
- If downloading, attempts to fetch maxresdefault (1280x720)
- Falls back to hqdefault (480x360) if maxresdefault is unavailable
- Saves the image to the specified location
Development
Setup
# Clone the repository
git clone https://github.com/yourusername/yt-thumbs.git
cd yt-thumbs
# Install in development mode
uv pip install -e .
Running Tests
# Run tests with coverage
uv run pytest --cov=src/yt_thumbs --cov-report=term-missing
# Or with dev dependencies installed
pytest
Code Quality
# Linting
ruff check src tests
# Format checking
ruff format --check src tests
# Format code
ruff format src tests
# Type checking
mypy src/yt_thumbs --strict
Requirements
- Python 3.10 or higher
- No external dependencies (uses standard library only)
License
MIT License - See LICENSE file for details
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Why yt-thumbs?
- Fast: No heavy dependencies like yt-dlp or pytube
- Simple: One command to get what you need
- Reliable: Uses YouTube's official thumbnail URLs
- Lightweight: Pure Python with standard library only
- Flexible: Get URLs or download files
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yt_thumbs-0.1.0.tar.gz.
File metadata
- Download URL: yt_thumbs-0.1.0.tar.gz
- Upload date:
- Size: 19.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1606ec1f89a0433e11e10231e55c61dbd73e724aedeef75758ae80fc340543bf
|
|
| MD5 |
e84a076094fbdac1f109a2c027bf8741
|
|
| BLAKE2b-256 |
e0a6c38871ca65334f7509364cfb27f9f6f6350024288a1f16590f2ac861c593
|
File details
Details for the file yt_thumbs-0.1.0-py3-none-any.whl.
File metadata
- Download URL: yt_thumbs-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba5639735f5440afb9f5f79e14cc49d9fc0516a29daeb0d06a0745bae9c18092
|
|
| MD5 |
f85c9e3aeefc7041c8f4022bb9b17e85
|
|
| BLAKE2b-256 |
69d5dcd3bd61987831f8d6ddf89d9e0019d2f7f4b67a4a98658d00efb819dfcb
|