Downloading a Youtube video is very useful for archiving interesting videos. But you can also download the Youtube video with metadata as well. The example below will download a Youtube video and the metadata as a json file. This is a great one-liner.
yt-dlp --embed-subs --embed-thumbnail --embed-metadata --output "%(uploader)s/%(title)s [%(id)s].%(ext)s" https://www.youtube.com/watch?v=VlvwDLGArzk |
Here is an example of the usage. This works very well.
┌──(john㉿DESKTOP-PF01IEE)-[/mnt/c/Users/Intel i5/Videos] └─$ yt-dlp --embed-subs --embed-thumbnail --embed-metadata --output "%(uploader)s/%(title)s [%(id)s].%(ext)s" https://www.youtube.com/watch?v=VlvwDLGArzk [youtube] VlvwDLGArzk: Downloading webpage [youtube] VlvwDLGArzk: Downloading android player API JSON [info] VlvwDLGArzk: Downloading 1 format(s): 247+258 [info] Downloading video thumbnail 41 ... [info] Writing video thumbnail 41 to: Flashback FM/Batman v Superman - Batmobile Chase [VlvwDLGArzk].webp WARNING: Requested formats are incompatible for merge and will be merged into mkv [download] Destination: Flashback FM/Batman v Superman - Batmobile Chase [VlvwDLGArzk].f247.webm [download] 100% of 19.45MiB in 00:07 [download] Destination: Flashback FM/Batman v Superman - Batmobile Chase [VlvwDLGArzk].f258.m4a [download] 100% of 11.86MiB in 00:06 [Merger] Merging formats into "Flashback FM/Batman v Superman - Batmobile Chase [VlvwDLGArzk].mkv" Deleting original file Flashback FM/Batman v Superman - Batmobile Chase [VlvwDLGArzk].f247.webm (pass -k to keep) Deleting original file Flashback FM/Batman v Superman - Batmobile Chase [VlvwDLGArzk].f258.m4a (pass -k to keep) [EmbedSubtitle] There aren't any subtitles to embed [Metadata] Adding metadata to "Flashback FM/Batman v Superman - Batmobile Chase [VlvwDLGArzk].mkv" [ThumbnailsConvertor] Converting thumbnail "Flashback FM/Batman v Superman - Batmobile Chase [VlvwDLGArzk].webp" to png [EmbedThumbnail] ffmpeg: Adding thumbnail to "Flashback FM/Batman v Superman - Batmobile Chase [VlvwDLGArzk].mkv" Deleting original file Flashback FM/Batman v Superman - Batmobile Chase [VlvwDLGArzk].webp (pass -k to keep) Deleting original file Flashback FM/Batman v Superman - Batmobile Chase [VlvwDLGArzk].png (pass -k to keep) |
The metadata is downloaded and then merged into the video as an MKV file. Below is an example of the metadata.
{"clickTrackingParams": "CAEQl98BIhMIh_qp3tLG9gIVTCiPCh3whwNb", "replayChatItemAction": {"actions": [{"clickTrackingParams": "CAEQl98BIhMIh_qp3tLG9gIVTCiPCh3whwNb", "addChatItemAction": {"item": {"liveChatViewerEngagementMessageRenderer": {"id": "CiMKIVJFUExBWV9WRU0yMDIyLzAzLzE0LTE1OjI2OjI2LjUzMw%3D%3D", "timestampUsec": "1647296786533585", "icon": {"iconType": "YOUTUBE_ROUND"}, "message": {"runs": [{"text": "Live chat replay is on. Messages that appeared during the Premiere will show up here."}]}}}}}], "videoOffsetTimeMsec": "0"}} |
This is a good Linux tip. Shows just how useful yt-dlp really is.