Error handling search

This commit is contained in:
2025-10-22 13:52:11 +02:00
parent 4e0748302e
commit 31eeff8890

View File

@@ -227,7 +227,7 @@ class DownloadQueue {
while (this.activeDownloads < this.maxConcurrency && this.queue.length > 0) {
const { url, folder, filename } = this.queue.shift()!;
this.activeDownloads++;
this.processDownload(url, folder, filename).then(() => {
this.activeDownloads--;
this.processQueue();
@@ -238,7 +238,7 @@ class DownloadQueue {
});
}
}
private async processDownload(url: string, folder: string, filename: string): Promise<void> {
await downloadSong(url, folder, filename);
songCount++;
@@ -261,6 +261,11 @@ for (const mentalState of mentalStates) {
authorization: `Bearer ${AUTHTOKEN}`
}
});
if (!response.ok) {
chalk.red("ERROR SEARCHING SONGS")
chalk.red(response.text());
continue;
}
const responseData = await response.json();
const data = formatAudioData(responseData.result);