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
(async function downloadCompleteHTML() { | |
// Helper function to fetch content of external files (CSS, JS, images) | |
async function fetchResource(url, isBinary = false) { | |
try { | |
const response = await fetch(url); | |
if (isBinary) { | |
const blob = await response.blob(); | |
return new Promise((resolve, reject) => { | |
const reader = new FileReader(); | |
reader.onloadend = () => resolve(reader.result); |
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
#change KEY_PATH, API_KEY, LIST_ID | |
#API_KEY https://blog.hubspot.com/website/how-to-get-youtube-api-key | |
#KEY_PATH https://cloud.google.com/docs/authentication/getting-started | |
#LIST_ID for ex. list_id in https://www.youtube.com/watch?v=fjYptQjF1Tw&list=RDfjYptQjF1Tw&start_radio=1 is "RDfjYptQjF1Tw" | |
import os | |
from googleapiclient.discovery import build | |
credential_path = "KEY_PATH" | |
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = credential_path |
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
#pip install pafy | |
#sudo pip install --upgrade youtube_dl | |
import cv2, pafy | |
url = "https://www.youtube.com/watch______" | |
video = pafy.new(url) | |
best = video.getbest(preftype="webm") | |
#documentation: https://pypi.org/project/pafy/ | |
capture = cv2.VideoCapture(best.url) |