Node-ytdl-core: Audio only and then()

Created on 12 Dec 2020  路  3Comments  路  Source: fent/node-ytdl-core

Hi i'm trying to download a video's audio stream only instead of converting it to mp3 after downloading as video. So far I just have this

ytdl('http://www.youtube.com/watch?v=' + id, { filter: 'audioonly', quality: 'lowestaudio' }).pipe(fs.createWriteStream('/tmp/file.mp3')).then(() => {}

But there is an error:
(node:13846) UnhandledPromiseRejectionWarning: TypeError: ytdl(...).pipe(...).then is not a function
at .../Desktop/F/Node/heroku/index.js:46:143
at Layer.handle [as handle_request] (.../Desktop/F/Node/heroku/node_modules/express/lib/router/layer.js:95:5)
at next (.../Desktop/F/Node/heroku/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (.../Desktop/F/Node/heroku/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (.../Desktop/F/Node/heroku/node_modules/express/lib/router/layer.js:95:5)
at .../Desktop/F/Node/heroku/node_modules/express/lib/router/index.js:281:22
at Function.process_params (.../Desktop/F/Node/heroku/node_modules/express/lib/router/index.js:335:12)
at next (.../Desktop/F/Node/heroku/node_modules/express/lib/router/index.js:275:10)
at SendStream.error (.../Desktop/F/Node/heroku/node_modules/serve-static/index.js:121:7)
at SendStream.emit (events.js:314:20)

Thank you so much!

not a bug

Most helpful comment

All 3 comments

Read. The. Docs. -> https://github.com/fent/node-ytdl-core#ytdlurl-options
ytdl does not return a Promise, it returns a readable stream, so obviously making a then call is just plain wrong

ah. I don't have experience with readable streams. Do you know any way to do things after the stream is finished? Thanks so much!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cloudrac3r picture cloudrac3r  路  5Comments

PKPear picture PKPear  路  4Comments

CheweyZ picture CheweyZ  路  6Comments

cloudrac3r picture cloudrac3r  路  5Comments

ajgeiss0702 picture ajgeiss0702  路  5Comments