Youtube video Templater with chapters and timecode links (and more data got from youtube API)

Hi!
I use YouTube heavily as a source of information and create a lot of “bibliographic” notes on videos, so I created a Templater template for that.

Template prompts a video url, then using yt-dlp get video metadata that includes some useful info like chapters with time codes, video duration, description, e.t.c. to be inserted in template.

Here is the code obsidian youtube templater · GitHub

created video page looks like this:

there is also notes section below with subheading for each video chapter:

time codes are external links that open a video in browser at corresponding time.

dependencies: yt-dlp and jq command line utils must be installed in system, details are in template comments.

My solution is based on someone else’s script (I don’t remember where I got it from), that ran one ytdlp process per one video property. The advantage of my template is that I make one call to yt-dlp -j "<video_url>" to query all fields at once in json, then use jq to filter out the results and not parse a huge json in obsidian runtime. This is much faster.

Hope, somebody will find this usable.

7 Likes

This looks great. I will have to try it out.

Do you think there is a way to add a screenshot of whatever time in video you specify?

I believe it’s impossible without downloading the entire video.

Cool template :tada: a few notes for other people who want to try it.

  • Needs Templater community plugin
  • If you run the flatpack version here is how i setup the cmd
sudo flatpak override md.obsidian.Obsidian --talk-name=org.freedesktop.Flatpak
sudo dnf install flatpak-spawn

and then the command looks like this →

flatpak-spawn --host yt-dlp -j "https://www.youtube.com/watch?v=${id}" | flatpak-spawn --host jq "${query}"

(@ll14m4n might be worth to look into the url parsing and support this as well)