yt-dlp_alexwlchan
A personal wrapper around yt-dlp that downloads and returns info in my preferred format
This is a personal wrapper around yt-dlp that downloads a video with thumbnails and subtitles, converts to my preferred formats, then prints some key information in a consistent JSON format.
$ yt-dlp_alexwlchan.py "https://www.youtube.com/watch?v=TUQaGhPdlxs"
{
"id": "TUQaGhPdlxs",
"url": "https://www.youtube.com/watch?v=TUQaGhPdlxs",
"title": "\"new york city, manhattan, people\" - Free Public Domain Video",
"description": "All videos uploaded to this channel are in the Public Domain: Free for use by anyone for any purpose without restriction. #PublicDomain",
"date_uploaded": "2022-03-25T01:10:38Z",
"video_path": "\uff02new york city, manhattan, people\uff02 - Free Public Domain Video [TUQaGhPdlxs].mp4",
"thumbnail_path": "\uff02new york city, manhattan, people\uff02 - Free Public Domain Video [TUQaGhPdlxs].jpg",
"subtitle_path": null,
"channel": {
"id": "UCDeqps8f3hoHm6DHJoseDlg",
"name": "Public Domain Archive",
"url": "https://www.youtube.com/channel/UCDeqps8f3hoHm6DHJoseDlg",
"avatar_path": "publicdomainarchive3052.png"
},
"site": "youtube"
}I have other scripts that know how to read this format, and it allows me to consolidate all my video-downloading logic in one place. Other scripts can call this script and get the title or description “for free”.
What it does
- Downloads the video, thumbnail, and subtitles to a temporary directory
- Convert the video to MP4 and the thumbnail to JPEG (my preferred formats)
- Gets some info about the video (title, description) and channel (name, URL, avatar URL)
- Prints all that info in a convenient JSON object
Installation
Clone the repo, create a virtualenv, and install dependencies:
$ git clone https://github.com/alexwlchan/yt-dlp_alexwlchan.git
$ cd yt-dlp_alexwlchan
$ python3 -m venv .venv
$ pip install -r requirements.txtThen save the following script somewhere in your PATH (replacing the cd with the root to your checkout):
#!/usr/bin/env bash
set -o errexit
set -o nounset
cd ~/repos/yt-dlp_alexwlchan
source .venv/bin/activate
python3 yt-dlp_alexwlchan.py "$@"Supported sites
yt-dlp supports a wide range of site, but I only map YouTube and Instagram with this tool.
Can other people use this?
You’re welcome to, but I wouldn’t recommend it. Partly because I don’t guarantee long-term stability or support, partly because you’ll have different preferences to me.
Instead, use this script as a starting point to write your own variant.
Why did you pick this name?
yt-dlp uses this name for its release variants (e.g. yt-dlp_linux, yt-dlp_win, yt-dlp_macos). This is my variant!
I’m not a yt-dlp contributor; this isn’t endorsed by or affiliated with yt-dlp. It’s just my wrapper around their project.