Get Thumbnail
Streaming
Get Thumbnail
Retrieve locally stored thumbnail images for downloaded videos with automatic format detection
GET
Get Thumbnail
Documentation Index
Fetch the complete documentation index at: https://mintlify.com/mario1027/offlinetube/llms.txt
Use this file to discover all available pages before exploring further.
Overview
This endpoint serves thumbnail images that were captured during the video download process. Thumbnails are automatically downloaded by yt-dlp and stored locally in the thumbnails directory for fast, reliable access.Endpoint
The unique identifier of the download task. This is the UUID returned when initiating a download via
POST /api/download.Response
Success (200)
Returns the thumbnail image file with appropriate content type.The MIME type of the thumbnail image, automatically detected based on file extension:
image/jpg- JPEG format (most common)image/webp- WebP format (modern, efficient)image/png- PNG format (lossless)
Size of the thumbnail image in bytes
The raw image file data
Supported Formats
The endpoint automatically detects and serves thumbnails in these formats (in order of preference):- JPEG (.jpg) - Default format from YouTube, typically 1280x720 or 640x480
- WebP (.webp) - Modern format with better compression
- PNG (.png) - Lossless format, larger file size
Format Detection Logic
The server checks for thumbnails in this order:- Fast lookups (typically finds .jpg on first try)
- Flexibility for different video sources
- No duplicate storage (only one format per task)
Thumbnail Creation Process
Thumbnails are created during video download through this workflow:- yt-dlp capture: The
writethumbnail: Trueoption tells yt-dlp to download the video’s thumbnail - Move to thumbnails directory: Downloaded thumbnails are moved from downloads to thumbnails folder
- Fallback download: If yt-dlp didn’t capture a thumbnail, the server downloads it from YouTube’s stable thumbnail URLs
- Format normalization: JPEG extensions are normalized (.jpeg → .jpg)
Fallback Behavior
If no local thumbnail exists, the API falls back to YouTube’s stable thumbnail URLs:/api/thumbnails/{task_id} endpoint only serves locally stored thumbnails.
Examples
Basic Request
Using in HTML
Embedding in Video Player
Fetching with JavaScript
Conditional Loading with React
Error Responses
Thumbnail not foundNo local thumbnail file exists for the specified task_id in any supported format (jpg, webp, png).Common causes:
- Invalid or non-existent task_id
- Thumbnail download failed during video processing
- Thumbnail was deleted from the thumbnails directory
- Download task hasn’t completed yet
File Storage Location
Thumbnails are stored in the server’s thumbnails directory:{task_id}.{ext}
Cleanup
Thumbnails are automatically deleted when:- Download removal: Calling
DELETE /api/downloads/{download_id}/removeremoves both the video file and thumbnail - The cleanup process checks all three formats:
Performance Characteristics
- Fast serving: Static files served directly from disk
- Small file sizes: Typically 20-100KB for JPEG thumbnails
- No transcoding: Images are served in their original format
- Disk cache friendly: Frequently accessed thumbnails stay in OS cache
Best Practices
- Check download status first: Ensure the download task is completed before requesting its thumbnail
- Handle 404s gracefully: Implement fallback images or placeholders for missing thumbnails
- Cache on client side: Browser caching significantly reduces server load
- Use task list endpoint: GET /api/downloads returns thumbnail URLs for all tasks
- Lazy loading: Load thumbnails only when needed (e.g., when scrolling into view)
Integration with Download List
TheGET /api/downloads endpoint returns thumbnail URLs that automatically use this endpoint for local thumbnails:
https://i.ytimg.com/vi/...).
Related Endpoints
- GET /api/downloads - List all downloads with thumbnail URLs
- DELETE /api/downloads//remove - Remove download and thumbnail
- GET /api/stream/ - Stream the associated video file