Skip to content

Instantly share code, notes, and snippets.

@dnicolson
Created February 15, 2025 15:42
Show Gist options
  • Save dnicolson/521e67deb823e2954ee09ecc21a457da to your computer and use it in GitHub Desktop.
Save dnicolson/521e67deb823e2954ee09ecc21a457da to your computer and use it in GitHub Desktop.
Like favorite YouTube videos
const playlistId = '';
let playlist = await youtube.getPlaylist(playlistId);
let videos = playlist.items;
while (playlist.has_continuation) {
playlist = await playlist.getContinuation();
videos = videos.concat(playlist.items);
}
for (const video of videos) {
const videoInfo = await youtube.getInfo(video.id);
if (videoInfo.basic_info.is_liked) {
console.log(`Video already liked: ${videoInfo.basic_info.title}`);
} else {
console.log(`Liking video: ${videoInfo.basic_info.title}`);
await videoInfo.like();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment