Fetch YouTube video metadata via the YouTube Data API v3 and print a table (Markdown by default).
- Python 3.9+
- A Google Cloud project with the YouTube Data API v3 enabled and an API key restricted to that API.
From the package directory (or from a parent repo that has this as tools/yt-extract):
pip install -e .Example from a parent repo's root:
pip install -e tools/yt-extractWith a venv active, the yt-extract command will be on your PATH.
Set your API key, then pass one or more video IDs:
export YOUTUBE_DATA_API_KEY=your_key
yt-extract dQw4w9WgXcQ
yt-extract VIDEO_ID_1 VIDEO_ID_2If you don’t pass any IDs, you’ll be prompted to enter them (comma- or space-separated):
yt-extract
# Enter video ID(s), comma- or space-separated: dQw4w9WgXcQBy default the script prints a Markdown table (id, title, publication date, channel title, view count, like count, comment count, duration), suitable for pasting into docs or viewing in a Markdown renderer. Use --format grid to print an ASCII grid instead.
Videos that are private, deleted, or not found are reported on stderr; the table includes only successfully fetched videos.
- Read from the
YOUTUBE_DATA_API_KEYenvironment variable. - If unset, the tool exits with instructions to set it.
- Do not commit your API key.
This project is licensed under the MIT License. See the LICENSE file for the full text.