How to download audio?
- Dominant language
- JavaScript
- Stars
- 4.7k
- Forks
- 852
- PR merge metrics
- No merged PRs in 30d
Description
From what the docs say this should work but it doesn't.
```js
const fs = require('fs')
const ytdl = require('ytdl-core')
async function download(link){
const info = await ytdl.getInfo(link)
let audioFormats = ytdl.filterFormats(info.formats, 'audioonly')
let format = ytdl.chooseFormat(audioFormats, {quality: 'highestaudio'})
console.log(format)
ytdl.downloadFromInfo(format)
}
let link = 'https://music.youtube.com/watch?v=7EJbFg_LxjY'
download(link)
```
```
throw Error('Cannot use `ytdl.downloadFromInfo()` when called ' +
^
Error: Cannot use `ytdl.downloadFromInfo()` when called with info from `ytdl.getBasicInfo()`
at ytdl.downloadFromInfo (/home/Idiot/Github/musicSync/node_modules/ytdl-core/lib/index.js:207:11)
at downloadSong (/home/Idiot/Github/musicSync/index.js:13:10)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.