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.

Revisions

  1. dnicolson created this gist Feb 15, 2025.
    19 changes: 19 additions & 0 deletions like-youtube-videos.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    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();
    }
    }