I use [[Templater]] and the YouTube [[oEmbed]] endpoint to quickly save metadata from videos and embed the video into a new note so I can watch the video directly in [[Obsidian]] and take notes. The oEmbed endpoint can be reached by updating the `videoURL` property of the following URL format ``` https://youtube.com/oembed?url=${videoURL}&format=json ``` The service returns a JSON object like ```json { "title":"Building a Productivity System (for Normal People)", "author_name":"Nick Houchin", "author_url":"https://www.youtube.com/@Nick.Houchin", "type":"video", "height":113, "width":200, "version":"1.0", "provider_name":"YouTube", "provider_url":"https://www.youtube.com/", "thumbnail_height":360,"thumbnail_width":480, "thumbnail_url":"https://i.ytimg.com/vi/N1oTJZ8D-dU/hqdefault.jpg", "html":"\u003ciframe width=\u0022200\u0022 height=\u0022113\u0022 src=\u0022https://www.youtube.com/embed/N1oTJZ8D-dU?feature=oembed\u0022 frameborder=\u00220\u0022 allow=\u0022accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\u0022 referrerpolicy=\u0022strict-origin-when-cross-origin\u0022 allowfullscreen title=\u0022Building a Productivity System (for Normal People)\u0022\u003e\u003c/iframe\u003e" } ``` To convert this into metadata, I use the following Templater script in the template [[YouTube]]. ```javascript const videoURL = await tp.system.prompt("Enter YouTube URL:"); if (!videoURL) { tR += "⚠️ No URL provided."; return; } // Function to clean illegal characters from filenames function cleanFileName(title) { const invalidChars = /[\\/:*?"<>|]/g; return title.replace(invalidChars, ""); } // Function to make YAML-safe text (handle colons & quotes) function makeYAMLSafe(text) { return `"${text.replace(/"/g, "'")}"`; // Wrap in quotes & replace double quotes with single quotes } // Fetch metadata from YouTube oEmbed API const data = await requestUrl({ url: `https://youtube.com/oembed?url=${videoURL}&format=json` }); const title = data.json.title; const cleanedTitle = cleanFileName(title); const truncatedTitle = cleanedTitle.length > 24 ? cleanedTitle.substring(0, 24) : cleanedTitle; const author = data.json.author_name; const thumbnailURL = data.json.thumbnail_url; const provider = data.json.provider_name; const providerURL = data.json.provider_url; // Set note title dynamically await tp.file.rename(cleanedTitle); // Format as markdown (cursor placement included) tR += `--- title: ${makeYAMLSafe(title)} author: "[[${author}]]" source: YouTube url: ${videoURL} thumbnail: ${thumbnailURL} --- By [[${author}]] on [${provider}](${providerURL}) ![embedded](${videoURL})`; ``` This script first creates an Untitled note and prompts the user for the URL. With the URL, the script goes to the YouTube oEmbed endpoint and grabs the metadata. It renames the note with a cleaned title and stores the remaining metadata in the YAML frontmatter. Finally it embeds the videoURL to watch directly in the note. In Templater settings, I assign this template to be run whenever I create a new note in my `lit/videos` folder. You could also use the QuickAdd plugin to similar effect. Make sure that Templater "Trigger template on new file creation" is on in settings and set the folder template for the `videos` folder to the YouTube template. Alternatively, you can use the Google YouTube API to get more detailed information, such as chapters, from the video (see this [implementation](https://www.reddit.com/r/ObsidianMD/comments/1j5fhl2/youtube_video_notetaking_workflow_via_quickadd/)). For me, that requires more overhead than it is worth right now.