No Examples Found
YouTube Downloader
This function downloads YouTube content at scale with support for video, audio, subtitles, and metadata extraction.
Key Features
- Multiple Content Types: Download videos, audio-only files, subtitles, or metadata.
- Resolution Options: Support for multiple resolutions from 144p to 8K.
- Video Segments: Extract specific portions of videos using the
start_time
andend_time
parameters. - Format Flexibility:
- Video formats: MP4, WebM
- Audio formats: MP3, WAV, M4A
- Subtitle Support: Download subtitles in multiple languages using ISO-639-1 codes.
- Rich Metadata: Access video details including title, thumbnail, description, tags, and duration, and more read here.
- Customizable Downloads: Mix and match features like combining video with metadata or subtitles.
Pricing
Download Type | Price |
---|---|
Video/Audio | $0.60 per GB |
Metadata | $0.01 per video |
Subtitles | $0.01 per language |
Example Cost Calculation
If you download a 1080p 30minutes video with metadata and subtitles in two languages:
- Video (0.5GB) = $0.60 * 0.5 = $0.3
- Metadata = $0.01
- Subtitles = $0.01 *2 = $0.02
- Total = $0.32
Notes
Response Format and Structure
Combined Output Order
When combining multiple output types (e.g., video with metadata and subtitles), the function yields results in the following sequence:
- Metadata dictionary (if requested)
- Media file (video or audio)
- Subtitles dictionary (if requested)
Video Downloads
- MP4: H.264 codec with audio (default)
- Resolution options: 144p to 8k
- Returns:
sieve.File
with .mp4 extension
- WebM: VP9 codec with audio
- Resolution options: 144p to 8K
- Returns:
sieve.File
with .webm extension
Audio Downloads
- MP3: Standard audio format (default)
- Returns:
sieve.File
with .mp3 extension
- Returns:
- WAV: Uncompressed audio format
- Returns:
sieve.File
with .wav extension
- Returns:
- M4A: AAC audio format
- Returns:
sieve.File
with .m4a extension
- Returns:
Supported Metadata Fields
The following metadata fields are supported:
-
id
: The unique YouTube ID of the video -
title
: The title of the video -
description
: The full description of the video -
duration
: Video duration in HH:MM:SS format -
upload_date
: The date when the video was uploaded (YYYY-MM-DD format) -
language
: The primary language of the video content (if available) -
channel_id
: The unique ID of the YouTube channel -
channel_follower_count
: The number of subscribers/followers of the channel -
view_count
: Number of views for the video -
like_count
: Number of likes for the video -
comment_count
: Number of comments on the video -
tags
: List of tags associated with the video -
categories
: List of categories the video belongs to -
vcodec
: Video codec used (e.g., "avc1", "vp9") -
acodec
: Audio codec used (e.g., "aac", "opus") -
aspect_ratio
: The aspect ratio of the video (e.g., 1.777 for 16:9) -
thumbnail
: Dictionary containing thumbnail URLs and dimensions at different resolutions{ "default": {"url": "...", "width": 120, "height": 90}, "medium": {"url": "...", "width": 320, "height": 180}, "high": {"url": "...", "width": 480, "height": 360} }
Example Metadata Response
{
"id": "dQw4w9WgXcQ",
"title": "Rick Astley - Never Gonna Give You Up (Official Music Video)",
"description": "The official music video for...",
"duration": "00:03:33",
"upload_date": "2009-10-25",
"language": "en",
"channel_id": "UCuAXFkgsw1L7xaCfnd5JJOw",
"channel_follower_count": 4210000,
"view_count": 1309283071,
"like_count": 15249333,
"comment_count": 1093394,
"tags": ["Rick Astley", "Never Gonna Give You Up", "music video"],
"categories": ["Music"],
"vcodec": "avc1.42001E",
"acodec": "mp4a.40.2",
"aspect_ratio": 1.777,
"thumbnail": {
"default": {"url": "https://i.ytimg.com/vi/dQw4w9WgXcQ/default.jpg", "width": 120, "height": 90},
"medium": {"url": "https://i.ytimg.com/vi/dQw4w9WgXcQ/mqdefault.jpg", "width": 320, "height": 180},
"high": {"url": "https://i.ytimg.com/vi/dQw4w9WgXcQ/hqdefault.jpg", "width": 480, "height": 360}
}
}
Notes on Metadata Fields
- Unavailable text fields will be returned as "NOT_FOUND"
- Unavailable numeric fields will be returned as 0
- Field availability varies by video - some videos may not have all fields populated
- When requesting metadata for specific resolution formats, fields like
vcodec
,acodec
, andaspect_ratio
will reflect the format that would be downloaded at that resolution
Subtitle Downloads
- Format: WebVTT (.vtt)
- Returns: Dictionary of
sieve.File
objects{ "en": sieve.File("path/to/subtitles.en.vtt"), "es": sieve.File("path/to/subtitles.es.vtt") }
Combined Downloads: Video, Subtitles, and Metadata
To download a video along with its subtitles and metadata in a single request:
- Set
download_type
to "video" - Enable additional content by setting:
include_subtitles
: Trueinclude_metadata
: True
- Customize your request with:
subtitle_languages
: List of language codes (e.g., ["en", "es"])metadata_fields
: List of desired metadata fields (e.g., ["title", "description"])
The function will return all requested components in a single response.
Extracting Video Clips
You can extract specific segments from a video or audio by using the time parameters:
start_time
: Beginning of the clip (in seconds)end_time
: End of the clip (in seconds)
This will return a clip from the original video or audio file containing only the content between the specified timestamps.
Fallback Mechanisms
The system implements resolution fallback mechanisms to handle cases where requested resolutions are unavailable. If a specific resolution cannot be found, the system will automatically select the nearest available resolution.
Important Notes:
- Fallback mechanisms are not enabled for:
- 8K resolution
- 4K resolution
- The system will raise an error if:
- 4K or 8K resolution is requested but unavailable
- WebM format is requested but unavailable
Format Availability
Some platforms have limited format availability:
- YouTube Shorts
- Instagram Reels
- TikTok videos
These platforms typically provide content in MP4 format only, and attempts to request WebM format for these sources will result in an error.