How to use the ytdl-core function in ytdl-core

To help you get started, we’ve selected a few ytdl-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LibreTubeApp / LibreTube / src / server.js View on Github external
server.use('/videoplayback', ensureLoggedIn(), (req, res) => {
    const { v: videoId } = req.query;

    // Default timeout is 5 minutes, which is too short for videos
    req.setTimeout(10 * 60 * 60 * 1000);

    if (!ytdl.validateID(videoId)) {
      res.status(400).send({
        error: 'VALIDATION_ERROR',
        reason: 'Invalid video id',
      });
      return;
    }

    ytdl(`https://youtube.com/watch?v=${videoId}`).pipe(res);
  });
github pedromsilvapt / unicast / src / Server / Providers / Youtube / YoutubeVideo.js View on Github external
createReadStream ( offset ) {
		let options = { quality: 'highest', filter: format => format.container === 'mp4' };

		if ( offset ) {
			options.range = offset.start + '-' + offset.end;
		}

		console.log( options );
		return ytdl( this.source, options );
	}
github whoisandy / yoda / src / scripts / YdmManager.js View on Github external
download(video, filename) {
    let url = `http://youtube.com/watch?v=${video.id}`;
    let writeStream = fs.createWriteStream(filename);
    let readStream = ytdl(url, {});
    readStream.pipe(writeStream);

    let download = {
      id: video.id,
      title: video.snippet.title,
      path: filename,
      stream: readStream
    };

    return new Promise((resolve, reject) => {
      readStream.on('error', err => {
        reject(err);
      });

      resolve(download);
    });
github bluedaniel / Kakapo-app / app / scripts / bridge / desktop / youtube.js View on Github external
eventChannel(emit => {
    let progress = 0;
    let fileSize = 0;
    let dataRead = 0;
    let newSound = {};

    const tmpFile = path.join(pathConfig.userSoundDir, shortid.generate());

    ytdl(`https://www.youtube.com/watch?v=${data.file}`, {
      format: 'audioonly',
      debug: true,
    })
      .on('response', ({ headers }) => {
        fileSize = headers['content-length'];
      })
      .on(
        'info',
        (
          { title, keywords, thumbnail_url: img, video_id: videoID },
          { container }
        ) => {
          newSound = {
            ...newSoundObj,
            file: path.join(
              pathConfig.userSoundDir,