How to get the title of youtbe video

I want to get the title of youtube video

What I’m trying to do

how to get the title of youtube video and put it into frontmattter.
i try to write frontmattter template with templater pluggin, but the program encountered an error while running.
who can help me.

Things I have tried

the template is below:

---
<%* 
let video_url = await tp.system.prompt("Enter the url of video");
let analysis_url = " https://youtube.com/oembed?url=" + video_url + "&format=json"
console.log(analysis_url)
const data = await requestUrl({url: analysis_url})
let title = data.json.title;
let author = data.json.author_name;
let save_folder_path = "/50-Inbox/"
await tp.file.move(save_folder_path + title) 
await tp.file.rename(title);
-%>
title: <% title %>
author: <% author %>
url: <% video_url %>
score: 
tags: 
  - youtube
date: <% tp.file.creation_date("YYYY-MM-DD") %>
aliases:
---

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.