增加了 HTTP 状态码检查:在调用音乐下载 API 时,如果返回的状态码不是 200(例如 403 Forbidden 或 500 Error),现在会记录错误并跳过,而不是尝试解析响应体。这应该能解决 Unexpected token F (可能是 "Forbidden" 或 "Failed") 导致的崩溃问题。
This commit is contained in:
@@ -160,6 +160,13 @@ function processSong(song) {
|
|||||||
const apiUrl = `https://music-dl.sayqz.com/api/?source=${source}&id=${song.id}&type=url&br=flac`;
|
const apiUrl = `https://music-dl.sayqz.com/api/?source=${source}&id=${song.id}&type=url&br=flac`;
|
||||||
|
|
||||||
https.get(apiUrl, (res) => {
|
https.get(apiUrl, (res) => {
|
||||||
|
if (res.statusCode !== 200) {
|
||||||
|
console.error(`[Sync] API Request Failed for ${song.name}: Status ${res.statusCode}`);
|
||||||
|
res.resume(); // Consume response data to free up memory
|
||||||
|
resolve();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let data = '';
|
let data = '';
|
||||||
res.on('data', chunk => data += chunk);
|
res.on('data', chunk => data += chunk);
|
||||||
res.on('end', () => {
|
res.on('end', () => {
|
||||||
@@ -192,6 +199,7 @@ function processSong(song) {
|
|||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('[Sync] API Parse Error:', e);
|
console.error('[Sync] API Parse Error:', e);
|
||||||
|
console.error('[Sync] Raw Response:', data);
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user