- Netease-sync/server.js
- 新增 formatSongLog
- 解析失败日志包含 id/source/apiUrl
- 下载失败日志包含 id/source/directUrl
This commit is contained in:
@@ -353,6 +353,13 @@ function buildDownloadCandidates(source, songId, songUrl, types) {
|
|||||||
return candidates;
|
return candidates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatSongLog(song, source) {
|
||||||
|
const name = song?.name || 'unknown';
|
||||||
|
const id = song?.id || 'unknown';
|
||||||
|
const src = source || song?.source || 'unknown';
|
||||||
|
return `${name} (id=${id}, source=${src})`;
|
||||||
|
}
|
||||||
|
|
||||||
async function tryDownloadWithCandidates(song, source, baseName, candidates, downloadHeaders) {
|
async function tryDownloadWithCandidates(song, source, baseName, candidates, downloadHeaders) {
|
||||||
const tried = new Set();
|
const tried = new Set();
|
||||||
|
|
||||||
@@ -362,7 +369,7 @@ async function tryDownloadWithCandidates(song, source, baseName, candidates, dow
|
|||||||
|
|
||||||
const directUrl = await resolveTuneHubAudioUrl(candidate.apiUrl);
|
const directUrl = await resolveTuneHubAudioUrl(candidate.apiUrl);
|
||||||
if (!directUrl) {
|
if (!directUrl) {
|
||||||
console.warn(`[Sync] Failed to resolve audio url for ${song.name} (${candidate.label})`);
|
console.warn(`[Sync] Failed to resolve audio url for ${formatSongLog(song, source)} (${candidate.label}) api=${candidate.apiUrl}`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,7 +419,7 @@ async function tryDownloadWithCandidates(song, source, baseName, candidates, dow
|
|||||||
return true; // Downloaded (fallback)
|
return true; // Downloaded (fallback)
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(`[Sync] Download failed for ${song.name} (${candidate.label}):`, err.message);
|
console.error(`[Sync] Download failed for ${formatSongLog(song, source)} (${candidate.label}) url=${directUrl}:`, err.message);
|
||||||
if (fs.existsSync(tempFile)) fs.unlinkSync(tempFile);
|
if (fs.existsSync(tempFile)) fs.unlinkSync(tempFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user