ytdlp.org
On this page

Developer guide

How to get video metadata with yt-dlp (without downloading)

Often you do not want the file at all — you want the title, duration, thumbnail, uploader, or the list of available formats. yt-dlp can extract all of it without downloading a byte of video, which makes it a surprisingly capable metadata tool for anything it can extract from.

Short answer: yt-dlp -j "URL" prints the full metadata as JSON without downloading the video, and --print returns just the fields you name. If downloads have to keep working inside an app, a hosted API such as Importly takes the link and returns the file, transcript or metadata, and it works from servers where self-hosted downloads get blocked, with nothing to install or patch on the box.

Quick answer

# Full metadata as JSON, no download
yt-dlp -j "URL"

# Just the fields you need
yt-dlp --print "%(title)s | %(duration)s | %(thumbnail)s" "URL"

-j prints one JSON object per video and skips the download entirely. --print is the shortcut when you only need a couple of fields and do not want to parse JSON at all.

The JSON is huge — these are the fields that matter

A single video's JSON can run to hundreds of kilobytes, most of it format variants. The fields people actually use:

  • title, duration (seconds), uploader, upload_date (YYYYMMDD)
  • thumbnail — the best thumbnail URL; thumbnails lists every size
  • formats — every available stream with resolution, codec, and bitrate
  • url inside each format — the direct media URL for that stream

One caveat that bites everyone: the direct media URLs are signed and expire after a few hours. They are fine for immediate playback or handing to a downloader right away, but useless in a database. Store the metadata and the original page URL; re-extract when you actually need a stream.

Playlists and channels: use flat extraction

Running -j on a playlist resolves every video individually — one network round-trip each, painfully slow on a large channel. If you only need the listing, tell yt-dlp not to resolve entries:

# Fast: IDs, titles, and URLs for every entry in one request batch
yt-dlp --flat-playlist -J "PLAYLIST_OR_CHANNEL_URL"

-J (uppercase) wraps the whole playlist in a single JSON object with an entries array. The flat entries carry less detail — no formats, sometimes no duration — so the usual pattern is: flat pass to enumerate, then a full -j per video only for the ones you care about.

In Python

The library equivalent is extract_info with download=False:

from yt_dlp import YoutubeDL

with YoutubeDL() as ydl:
    info = ydl.extract_info(url, download=False)
    data = ydl.sanitize_info(info)  # JSON-safe dict

print(data["title"], data["duration"], data["thumbnail"])

sanitize_info strips the internal objects so the dict serializes cleanly. For the full library walkthrough — options, error handling, library vs subprocess — see the Python guide.

The mistake to avoid

Do not scrape metadata at scale from a single IP. Rapid-fire extraction requests with no downloads in between is exactly the request pattern YouTube's bot checks are tuned to catch, and the failure mode is the "Sign in to confirm you're not a bot" wall — which blocks metadata extraction just as thoroughly as it blocks downloads. Rate-limit your own crawler before YouTube does it for you. If you need this inside an app, say a preview card when a user pastes a link, this Node recipe gets the title, thumbnail and length from one API call and caches the result. The same route for a Python backend is the FastAPI recipe.

For builders

Using yt-dlp inside an app or script?

Paste a link to see what a managed media-import API returns — no install, no signup.

Building this into an app? See the API your backend calls instead