Created
July 28, 2017 00:30
-
-
Save milankragujevic/cf0e503407104b1e444efa18f4108ce1 to your computer and use it in GitHub Desktop.
To extract all the video IDs from a YouTube playlist. Open the playlist page, scroll down to the bottom, click load more, repeat until the end, then open Console and paste this code. Output is a list of video IDs from the page.
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
var els = document.getElementsByClassName('pl-video'); | |
for(i = 0; i < els.length; i++) { | |
var el = els[i]; | |
if(el) { | |
var src = el.getElementsByClassName('yt-thumb-clip')[0].getElementsByTagName('img')[0].src; | |
if(!src.match(/\.com\/vi\//g)) { continue; } | |
var id = src.split('.com/vi/')[1].split('/')[0]; | |
console.log(id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
why not use yt-dlp? In a console with yt-dlp installed, execute:
replace
PLAYLIST_URL
with the url and exec the cmd. This will give the entire urls in a txt file. Then in the file, simply find and replacehttps://www.youtube.com/watch?v=
with nothing.