Error if formats.some(fmt => fmt.isHLS)
- Dominant language
- JavaScript
- Stars
- 4.7k
- Forks
- 852
- PR merge metrics
- No merged PRs in 30d
Description
I'm using the latest version of ytdl-core
My goal is to download the video and transform it into mp3 and send it, I'm using a whatsapp library but it's working perfectly what's giving me the problem is in fact the ytdl-core
I used several checks and logs to verify the error but it still falls straight into the error
```JavaScript
if (message.body.startsWith('/yt ')) {
console.log(formats); // Imprime o valor de formats
if (Array.isArray(formats)) {
if (formats.some(fmt => fmt.isHLS)) {
const videoUrl = message.body.slice(4);
const videoId = ytdl.getURLVideoID(videoUrl);
console.log(`videoId: ${videoId}`); // Imprime o valor de videoId
const info = await ytdl.getInfo(videoId);
console.log(info); // Imprime o valor de retorno de ytdl.getInfo(videoId)
if (Array.isArray(info.formats)) {
const audioFormat = ytdl.chooseFormat(info.formats, { quality: 'highestaudio' });
const audioFile = fs.createWriteStream('audio.mp3');
await ytdl(videoUrl, { format: audioFormat })
.pipe(audioFile);
audioFile.on('finish', () => {
message.reply(new MessageMedia('audio/mp3', fs.readFileSync('audio.mp3')));
console.log('Sent audio file');
});
} else {
console.error('info.formats is not an array');
}
}
} else {
console.error('formats is not an array');
}
}
```

This is the error displayed
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.