Playlists

ytdlp-nodejs fully supports downloading and fetching information from playlists.

Get Playlist Information

1import { YtDlp } from 'ytdlp-nodejs';
2
3const ytdlp = new YtDlp();
4
5async function getPlaylistInfo() {
6  const info = await ytdlp.getInfoAsync(
7    'https://www.youtube.com/playlist?list=PLrAXtmErZgOeiKm4sgNOknGvNjby9efdf',
8  );
9
10  if (info._type === 'playlist') {
11    console.log('Playlist title:', info.title);
12    console.log('Video count:', info.entries?.length);
13
14    // List all videos in the playlist
15    info.entries?.forEach((entry, index) => {
16      console.log(`${index + 1}. ${entry.title}`);
17    });
18  }
19}
20
21getPlaylistInfo();

Download Entire Playlist

1import { YtDlp } from 'ytdlp-nodejs';
2
3const ytdlp = new YtDlp();
4
5async function downloadPlaylist() {
6  await ytdlp.downloadAsync(
7    'https://www.youtube.com/playlist?list=PLrAXtmErZgOeiKm4sgNOknGvNjby9efdf',
8    {
9      output: './playlist/%(playlist_index)s - %(title)s.%(ext)s',
10      onProgress: (p) => {
11        console.log(`Downloading: ${p.percentage_str}`);
12      },
13    },
14  );
15}
16
17downloadPlaylist();

Download Specific Videos from Playlist

Use playlistItems to select specific videos:

1await ytdlp.downloadAsync(playlistUrl, {
2  playlistItems: '1-5', // First 5 videos
3  // playlistItems: '1,3,5', // Videos 1, 3, and 5
4  // playlistItems: '5-',    // From video 5 to the end
5});

Playlist Options

Option Description
flatPlaylist Only get video IDs, not full info (faster)
playlistStart Start from this video index
playlistEnd Stop at this video index
playlistItems Specific items to download (e.g., "1-3,5")
playlistReverse Download in reverse order
playlistRandom Download in random order

Channel Downloads

You can also download from YouTube channels:

1// Download all videos from a channel
2await ytdlp.downloadAsync('https://www.youtube.com/@ChannelName/videos', {
3  output: './channel/%(upload_date)s - %(title)s.%(ext)s',
4  dateafter: '20240101', // Only videos after this date
5});