BrightData YouTube Scraper
YouTube data collection using BrightData's Datasets API. All operations save results to disk and return summaries to context.
Quick Start
Single Video:
python skills/brightdata-youtube/scripts/fetch.py \
--endpoint videos \
--input "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
Channel Info:
python skills/brightdata-youtube/scripts/fetch.py \
--endpoint channels \
--input "https://www.youtube.com/@brightdata"
Channel by Name (no URL needed):
python skills/brightdata-youtube/scripts/fetch.py \
--endpoint channels \
--channel-name "brightdata"
Search YouTube:
python skills/brightdata-youtube/scripts/fetch.py \
--endpoint search \
--keyword "SEO tutorial" \
--pages-to-search 3 \
--type video
Comments from Video:
python skills/brightdata-youtube/scripts/fetch.py \
--endpoint comments \
--input "https://www.youtube.com/watch?v=dQw4w9WgXcQ" \
--num-of-comments 50
YouTube Short:
python skills/brightdata-youtube/scripts/fetch.py \
--endpoint shorts \
--input "https://www.youtube.com/shorts/SXHMnicI6Pg"
Video Transcript:
python skills/brightdata-youtube/scripts/fetch.py \
--endpoint transcripts \
--input "https://www.youtube.com/watch?v=dQw4w9WgXcQ" \
--language en
Available Endpoints
| Endpoint | Dataset ID | Input Type | Description |
|---|---|---|---|
videos |
gd_lk5ns7kz21pck8jpis |
Video URLs | Collect video data by URL |
channels |
gd_ytc26hd9r2fhaq2i0g |
Channel URLs or name | Collect channel data |
comments |
gd_lk5ns7kz21pck8jpis |
Video URLs | Collect comments from a video |
search |
gd_lwdb9kf1cj0lf1doa0 |
Keyword or search URL | Search YouTube |
shorts |
gd_lz29oxyn3ry9mfpbs |
Shorts URLs | Collect YouTube Shorts data |
transcripts |
gd_lz2915ty3pd2o05i2m |
Video URLs | Collect video transcripts/subtitles |
Parameters
Common Parameters
| Parameter | Required | Default | Description |
|---|---|---|---|
--endpoint |
Yes | - | Endpoint type (see table above) |
--input |
Conditional | - | URL or path to batch file |
--batch |
No | false | Enable batch mode for file inputs |
--mode |
No | sync | API mode: sync or async |
Channel Parameters (channels)
| Parameter | Required | Description |
|---|---|---|
--channel-name |
No | Channel handle/name without @ (alternative to --input URL) |
Search Parameters (search)
| Parameter | Required | Description |
|---|---|---|
--keyword |
Yes* | Search query (*or use --input with search URL) |
--pages-to-search |
No | Number of result pages to collect (default: 1) |
--type |
No | Filter: video, channel, playlist |
Comments Parameters (comments)
| Parameter | Required | Description |
|---|---|---|
--num-of-comments |
No | Max comments to return (default: 100) |
--days-posted |
No | Only comments from last N days |
Transcript Parameters (transcripts)
| Parameter | Required | Description |
|---|---|---|
--language |
No | Preferred transcript language code (e.g., en) |
Timing Parameters
| Parameter | Default | Description |
|---|---|---|
--timeout |
120 | Request timeout in seconds |
--max-wait |
300 | Max polling wait time in seconds |
--poll-interval |
5 | Polling interval in seconds |
Batch Operations
JSON Format (URLs)
{
"urls": [
"https://www.youtube.com/watch?v=video1",
"https://www.youtube.com/watch?v=video2"
]
}
Search Batch
{
"searches": [
{"keyword": "SEO tools", "pages_to_search": 3},
{"keyword": "link building", "type": "video"},
{"keyword": "technical SEO"}
]
}
TXT Format
https://www.youtube.com/watch?v=video1
https://www.youtube.com/watch?v=video2
Async Mode
For large batches, use async mode:
# Submit async request
python skills/brightdata-youtube/scripts/fetch.py \
--endpoint videos \
--input video_urls.json \
--batch \
--mode async
# Check status and retrieve results
python skills/brightdata-youtube/scripts/status.py \
--snapshot-id <snapshot_id>
Output Format
{
"success": true,
"endpoint": "search",
"mode": "sync",
"record_count": 25,
"output_file": "output/brightdata_youtube_search_20250327T123456.json",
"summary": "Successfully scraped 25/25 YouTube search",
"stats": {
"total_inputs": 1,
"successful": 25,
"failed": 0
}
}
Video Output Fields
id/url- Video identifier and URLtitle/description- Video title and descriptionchannel/channel_url/channel_id- Channel infochannel_subscribers- Subscriber countviews/likes/comments_count- Engagement metricspublished_date/duration- Timing infothumbnail- Thumbnail URLtags/category- Classificationis_live/is_short- Video type flagslanguage/subtitles_available- Language info
Channel Output Fields
id/url/title- Channel identifiersdescription- Channel descriptionsubscriber_count/video_count/view_count- Metricsjoined_date/country- Profile infoavatar/banner- Imagesis_verified- Verification statuslinks- External linksvideos- List of channel videos (array)
Comment Output Fields
video_id/video_title- Parent video infocomments[].comment_id/comments[].author- Comment identifierscomments[].text/comments[].published_date- Contentcomments[].likes/comments[].reply_count- Engagementcomments[].replies- Nested reply threadstotal_comments- Total count
Transcript Output Fields
video_id/video_title- Video infolanguage/is_auto_generated- Transcript metadatatranscript[].text/transcript[].start/transcript[].duration- Timestamped segmentsfull_text- Complete transcript as single stringavailable_languages- Available language codes
API Configuration
Requires BRIGHTDATA_API_TOKEN in .env:
BRIGHTDATA_API_TOKEN=your_api_token_here
Limitations
- Rate limits depend on BrightData plan
- Platform ToS: ensure compliance with YouTube's Terms of Service
- URL formats: requires valid YouTube URLs
- Video and Comments share the same dataset_id; differentiated by input parameters