How to use the ytdl-core.filterFormats 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 mihirpathak97 / audius / src / modules / YTDownload.js View on Github external
ytdl.getInfo(, infoOptions, function(err, info) {
      if (err) {
        log.error('YTDownload', JSON.stringify(err));

      var downloadOptions = {
        quality: 'highestaudio',
        requestOptions: { maxRedirects: 5 },
        format: ytdl.filterFormats(info.formats, 'audioonly')[0]

      // Setup stream
      var stream = ytdl.downloadFromInfo(info, downloadOptions);
      stream.on("response", function(httpResponse) {

        // TODO: Add event emitter to share progress with caller

        // Build progress var
        var str = progress({
          length: parseInt(httpResponse.headers["content-length"], 10),
          time: 1000

        // Stream progress listener
        str.on("progress", function(progress) {