I'm using spotdl in my nestJs project. and i get this error when trying to use it. error : AudioProviderError: YT-DLP download error - implemented it like this :
const spotDl = spawn('spotdl', [
'download',
url,
'--output',
`${songDir}/%(title)s.%(output-ext)s`,
]);
spotDl.on('close', (code) => {
setTimeout(() => {
if (code === 0) {
// get all mp3 files in the song directory
const files: string[] = readdirSync(songDir)
.filter((f): boolean => f.endsWith('.mp3'))
.map((file): string => path.join(songDir, file));
// resolve the promise
resolve({
filePaths: files.length ? files : undefined,
error: undefined,
});
} else {
// resolve the promise with error message
console.log(
'error in spotify service on spawn close',
errorMessage,
);
resolve({
filePaths: undefined,
error: errorMessage || 'Unknown error occurred',
});
}
}, 500);
});
i expect it to download the file from the link i give to it but it response with this error everytime.