Skip to content

Instantly share code, notes, and snippets.

@moalex
Forked from spyesx/youtube_watch_later.js
Created August 22, 2022 15:15
Show Gist options
  • Save moalex/456eddd856323c1aa805979b74b41775 to your computer and use it in GitHub Desktop.
Save moalex/456eddd856323c1aa805979b74b41775 to your computer and use it in GitHub Desktop.
Get URLs of your youtube watch later playlist
// Execute this in the console of on your own playlist
var videos = document.querySelectorAll('.yt-simple-endpoint.style-scope.ytd-playlist-video-renderer');
var r = [];
var json = [];
r.forEach.call(videos, function(video) {
var url = 'https://www.youtube.com' + video.getAttribute('href');
url = url.split('&list=WL&index=');
url = url[0];
json.push(url);
});
console.log(json)
## As @jwillmer said in the comment, we want to use bash, not sh
# chmod 744 youtube_watch_later.sh
# ./youtube_watch_later.sh
#!/bin/bash
declare -a videos=(
"https://www.youtube.com/watch?v=5dsGWM5XGdg"
"https://www.youtube.com/watch?v=2J5GzHoKl1Q"
)
for i in "${videos[@]}"
do
youtube-dl -i -c --write-thumbnail -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' "$i"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment