Created
December 27, 2022 16:45
-
-
Save RubenZagon/78a579ea1f126d77146fa51f12ac7c71 to your computer and use it in GitHub Desktop.
Revisions
-
RubenZagon created this gist
Dec 27, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,66 @@ <%* videoUrl = await tp.system.prompt("URL del vídeo de YouTube"); async function getVideoData() { const videoId = videoUrl.substring(32); const apiKey = 'YOUR_API_KEY'; const url = `https://www.googleapis.com/youtube/v3/videos?part=snippet&id=${videoId}&key=${apiKey}`; try { const response = await fetch(url); const data = await response.json(); if (response.ok) { const video = data.items[0].snippet; title = video.title; author = video.channelTitle; publish_date = video.publishedAt.match(/\d{4}-\d{2}-\d{2}/g)[0]; year = video.publishedAt.match(/\d{4}/g)[0]; id = videoId; await tp.file.rename(`${author} - ${title}`) } else { quote = "An error ocurred"; console.log(data); } } catch (error) { console.error(error); } } await getVideoData(); tR += "---"; // Hack para evitar que haya un salto de línea extra en la cabecera %> <%* if (title.toLowerCase().contains("java")) { tR += "tags: fuentes/youtube en/java #en/" } else { tR += "tags: fuentes/youtube #en/" } %> published_on: <%* tR +=`${publish_date}` %> alias: <%* tR += `${year}` %> 📺 <%* tR += `${title}` %> --- Author:: [[<%* tR += `${author}` %>]] URL:: <%* tR += `${videoUrl}` %> # <%* tR += `${title}` %> <%* tR += `<iframe width="560" height="315" src="https://www.youtube.com/embed/${id}" title="YouTube video player" frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen></iframe> ` %> ## Links <%* if (title.toLowerCase().contains("java")) { tR += "[[Java]]" } %> <%* await tp.file.move(`/💧 Fuentes/📺 Videos/${title}`) %>