Skip to content

Instantly share code, notes, and snippets.

@hed0rah
Created April 18, 2026 21:18
Show Gist options
  • Select an option

  • Save hed0rah/e93339f87ea05bac297c8164a9ebcf9e to your computer and use it in GitHub Desktop.

Select an option

Save hed0rah/e93339f87ea05bac297c8164a9ebcf9e to your computer and use it in GitHub Desktop.
yt-dlp Metadata extraction

yt-dlp Cheatsheet: Metadata, Playlists & Lists

(No downloads — just metadata extraction)

All commands below use simulation mode by default (no video/audio is ever downloaded).
Add > output.txt (or > output.csv) at the end to save to a file, just like your example.

1. Core Flags You’ll Use Most

Flag Purpose
--flat-playlist Treat playlist as a flat list of videos (fast, no deep expansion)
--print "TEMPLATE" or -O "TEMPLATE" Print exactly what you want (title, URL, etc.)
-J Dump entire playlist as one big JSON
-j Dump one JSON per video
-s or --skip-download Extra safety (forces simulation)
--print-to-file "TEMPLATE" "file.txt" Write output straight to file (newer, cleaner than >)

2. Your Exact Example (Playlist → Pipe-Separated List)

yt-dlp --flat-playlist --print "%(title)s|||%(channel)s|||%(url)s" \
"https://www.youtube.com/playlist?list=PLKdwl-SNv8noUYKS7E__f3CILMckG4rD_" > skate_playlist.txt

3. Popular Playlist Metadata Commands

Simple title + URL list yt-dlp --flat-playlist --print "%(title)s | %(url)s" PLAYLIST_URL

CSV-style (title, channel, duration, views, upload date) yt-dlp --flat-playlist --print "%(title)s,%(channel)s,%(duration)s,%(view_count)s,%(upload_date)s"
PLAYLIST_URL > playlist.csv

TSV (tab-separated — great for spreadsheets) yt-dlp --flat-playlist --print "%(playlist_index)03d\t%(title)s\t%(channel)s\t%(url)s"
PLAYLIST_URL > playlist.tsv

Numbered playlist with uploader & duration (human-readable) yt-dlp --flat-playlist --print "%(playlist_index)03d - %(title)s | %(channel)s | %(duration_string)s"
PLAYLIST_URL

Full playlist metadata (title, uploader, total videos) yt-dlp --flat-playlist --print "%(playlist_title)s by %(playlist_uploader)s — %(n_entries)s videos"
PLAYLIST_URL

4. JSON Power Moves (Best for Scripting)

One JSON file with the whole playlist + all videos yt-dlp -J PLAYLIST_URL > playlist_full.json

Flat playlist as one JSON (just the list, no extra data) yt-dlp --flat-playlist -J PLAYLIST_URL > playlist_flat.json

One JSON per video (pipe to jq or process individually) yt-dlp --flat-playlist -j PLAYLIST_URL > videos.jsonl # JSON Lines format

Just the playlist title (super fast) yt-dlp --flat-playlist --print "%(playlist_title)s" PLAYLIST_URL

5. Single Video Metadata

Title only yt-dlp --print "%(title)s" VIDEO_URL

All important fields (CSV style) yt-dlp --print "%(title)s|||%(channel)s|||%(upload_date)s|||%(duration_string)s|||%(view_count)s|||%(url)s" VIDEO_URL

Full metadata JSON yt-dlp -j VIDEO_URL > metadata.json

6. Channel Playlists / Uploads

List all videos in a channel (latest uploads) yt-dlp --flat-playlist --print "%(title)s | %(url)s" "https://www.youtube.com/channel/CHANNEL_ID/videos"

Channel name + follower count yt-dlp --print "%(channel)s — %(channel_follower_count)s followers" CHANNEL_URL

7. Useful Output Template Tricks

What you want Template
Zero-padded index %(playlist_index)03d
Truncate title to 80 chars %(title).80s
Formatted date %(upload_date>%Y-%m-%d)s
Safe filename-friendly title %(title).100B (B = bytes, safe chars)
Default value if missing `%(like_count
Multiple prints (multi-column) Use multiple --print flags

Example: Fancy CSV with safe titles yt-dlp --flat-playlist
--print "%(playlist_index)03d,%(title).100B,%(channel)s,%(upload_date>%Y-%m-%d)s,%(duration_string)s,%(url)s"
PLAYLIST_URL > clean_playlist.csv

8. Quick Reference: Most Useful Fields

  • title, channel, uploader, url (video link)
  • playlist_title, playlist_uploader, n_entries, playlist_index
  • duration, duration_string
  • view_count, like_count
  • upload_date, timestamp
  • id, webpage_url, thumbnail
  • description (use with caution — very long)

9. Pro Tips

  • Always test without > file first to see output.
  • For huge playlists, --flat-playlist is much faster.
  • Pipe to jq for JSON: yt-dlp -J URL | jq .title
  • Use --ignore-errors if some videos are private/deleted.
  • --print-to-file is cleaner than shell redirection for complex cases.

Copy-paste any of the commands above and just replace PLAYLIST_URL or VIDEO_URL.

Enjoy your metadata wrangling! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment