fent / fent/node-ytdl-core

How to download audio?

Open
#1,212 6 comments 0 reactions 0 assignees View on GitHub
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.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.