改动位置
- Netease-sync/server.js
- 记录 downloadStatus
- 记录 unmatchedSongs
- 输出 [Sync] Unmatched songs (N): ... (id=..., downloaded=...)
This commit is contained in:
@@ -771,6 +771,8 @@ async function syncPlaylist(playlist, cachedInfo = null) {
|
|||||||
const totalTracks = tracks.length;
|
const totalTracks = tracks.length;
|
||||||
let syncedCount = 0;
|
let syncedCount = 0;
|
||||||
let failedCount = 0;
|
let failedCount = 0;
|
||||||
|
const downloadStatus = {};
|
||||||
|
const unmatchedSongs = [];
|
||||||
|
|
||||||
syncStatus[playlistId] = { status: 'syncing', progress: 10, message: `获取到 ${totalTracks} 首歌曲` };
|
syncStatus[playlistId] = { status: 'syncing', progress: 10, message: `获取到 ${totalTracks} 首歌曲` };
|
||||||
|
|
||||||
@@ -796,9 +798,11 @@ async function syncPlaylist(playlist, cachedInfo = null) {
|
|||||||
const batch = songs.slice(i, i + BATCH_SIZE);
|
const batch = songs.slice(i, i + BATCH_SIZE);
|
||||||
await Promise.all(batch.map(async (song) => {
|
await Promise.all(batch.map(async (song) => {
|
||||||
try {
|
try {
|
||||||
await processSong(song);
|
const ok = await processSong(song);
|
||||||
|
downloadStatus[song.id] = ok;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`[Sync] Failed to process song ${song.name}:`, e);
|
console.error(`[Sync] Failed to process song ${song.name}:`, e);
|
||||||
|
downloadStatus[song.id] = false;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -846,6 +850,13 @@ async function syncPlaylist(playlist, cachedInfo = null) {
|
|||||||
syncedCount++;
|
syncedCount++;
|
||||||
} else {
|
} else {
|
||||||
failedCount++;
|
failedCount++;
|
||||||
|
unmatchedSongs.push({
|
||||||
|
id: neteaseSongId,
|
||||||
|
name: song.name,
|
||||||
|
artist: song.artist,
|
||||||
|
album: song.album,
|
||||||
|
downloaded: downloadStatus[neteaseSongId] === true
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const progress = 80 + Math.floor((i + 1) / songs.length * 15); // 80% -> 95%
|
const progress = 80 + Math.floor((i + 1) / songs.length * 15); // 80% -> 95%
|
||||||
@@ -857,6 +868,14 @@ async function syncPlaylist(playlist, cachedInfo = null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
syncStatus[playlistId] = { status: 'syncing', progress: 95, message: '更新 Navidrome 歌单...' };
|
syncStatus[playlistId] = { status: 'syncing', progress: 95, message: '更新 Navidrome 歌单...' };
|
||||||
|
|
||||||
|
if (unmatchedSongs.length > 0) {
|
||||||
|
const maxLog = 20;
|
||||||
|
const preview = unmatchedSongs.slice(0, maxLog)
|
||||||
|
.map(s => `${s.name} - ${s.artist} (id=${s.id}, downloaded=${s.downloaded})`)
|
||||||
|
.join(' | ');
|
||||||
|
console.warn(`[Sync] Unmatched songs (${unmatchedSongs.length}): ${preview}${unmatchedSongs.length > maxLog ? ' ...' : ''}`);
|
||||||
|
}
|
||||||
|
|
||||||
// 1. Try to link existing Navidrome playlist by name if ID is missing
|
// 1. Try to link existing Navidrome playlist by name if ID is missing
|
||||||
if (!playlist.navidromePlaylistId) {
|
if (!playlist.navidromePlaylistId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user