Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playlist support? #73

Open
milesflo opened this issue Dec 18, 2017 · 3 comments
Open

Playlist support? #73

milesflo opened this issue Dec 18, 2017 · 3 comments
Labels

Comments

@milesflo
Copy link

It'd be nice to have a playlist flag that would iterate over an API call to get all of the videos in a playlist and download them into the current directory.

@milesflo
Copy link
Author

Feature Request ^

@Ishidres
Copy link

Ishidres commented Nov 8, 2019

I agree, that feature would be awesome to have!
Any update so far? :)

@mifi
Copy link

mifi commented Apr 26, 2020

Maybe better to use something like this https://github.com/tjrgg/simple-youtube-api/blob/master/examples/playlist.js
it requires an api key though...

EDIT:
Oh this one:
https://github.com/TimeForANinja/node-ytpl

This works:

const fs = require('fs');
const ytdl = require('ytdl-core');
const ytpl = require('ytpl');

const limit = 2;
const playlistId = 'UUht8qITGkBvXKsR1Byln-wA';

(async () => {
  const playlist = await ytpl(playlistId);
  const items = playlist.items.slice(0, limit);
  console.log(items);

  for (const { id, title, url } of items) {
    console.log('Downloading', title);
    const stream = ytdl(url).pipe(fs.createWriteStream(`${id}.mp4`));
    await new Promise((resolve, reject) => {
      stream.on('finish', resolve);
      stream.on('error', reject);
    });
  }
})().catch(console.error);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants