Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save milankragujevic/cf0e503407104b1e444efa18f4108ce1 to your computer and use it in GitHub Desktop.
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.
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);
}
}
@piru72
Copy link

piru72 commented Aug 10, 2023

Great currently using the official youtube data api to get the work done

@zeeid
Copy link

zeeid commented Nov 23, 2023

var els = document.getElementsByClassName('yt-simple-endpoint style-scope ytd-playlist-video-renderer');
var show="";
for(i = 0;i<els.length;i++){
    var el = els[i];
	show += (el.href.split('?v=')[1].split('&list')[0] + "\n");
}
console.log(show);

i used this

Work thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment