Last active
February 23, 2025 17:16
-
-
Save arbaaz/2680c43bae4ec8a21fbe2baa4b7b4115 to your computer and use it in GitHub Desktop.
Notebook LLM upload youtube URLs (Steps at the bottom)
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 characters
const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms)); | |
async function uploadYoutubeVideo(url) { | |
console.log("clicking upload button") | |
await Promise.race([ | |
new Promise((resolve, reject) => { | |
try { | |
document.querySelector("button.add-source-button")?.click(); | |
resolve(); | |
} catch (e) { | |
reject(e); | |
} | |
}), | |
new Promise((resolve, reject) => { | |
try { | |
document.querySelector("button.upload-button")?.click(); | |
resolve(); | |
} catch (e) { | |
reject(e); | |
} | |
}) | |
]); | |
console.log("clicking youtube button") | |
await delay(1000); | |
const elements = document.querySelectorAll('span.mdc-evolution-chip__text-label.mat-mdc-chip-action-label'); | |
const youtubeElement = Array.from(elements).find(el => el.textContent.trim().toLowerCase() === 'youtube'); | |
if (youtubeElement) { | |
youtubeElement.click(); | |
} else { | |
console.error("Youtube button not found"); | |
} | |
console.log("inputting url") | |
await delay(1000); | |
const input = document.querySelector(".mat-mdc-form-field-infix > input"); | |
input.value = url; | |
const event = new Event('input', { bubbles: true }); | |
input.dispatchEvent(event); | |
console.log("clicking insert button") | |
await delay(1000); | |
Array.from(document.querySelectorAll("button[type='submit']")) | |
.find(button => button.textContent.trim() === "Insert") | |
?.click(); | |
} | |
// https://youtu.be/Cnkk2Ginv24?si=NC3aNQ439nAv36ZA | |
// Get the list of videos from the youtube page | |
// LLM Pro can have 300 | |
// Normal can have 50 | |
const videos = [ | |
"https://youtu.be/Cnkk2Ginv24?si=NC3aNQ439nAv36ZA" | |
] | |
videos.reduce(async (acc, item) => {await acc; await delay(5000); return uploadYoutubeVideo(item)}, Promise.resolve()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Step 1:
Goto Channels video page https://www.youtube.com/@LennysPodcast/videos
Step 2:
Scroll to the bottom to see all video so that we can copy all the links
Step 3:
Run below command in chrome devtools console. It should copy all the video links to your clipboard.
Step 4:
Paste all the links on line number 53 in
uploadYoutubeVideos.js
fileStep 5:
Copy full
uploadYoutubeVideos.js
on paste in the console of notebook llm page. It should start working.