diff --git a/Netease-sync/server.js b/Netease-sync/server.js index 488e6ea..afd4b21 100644 --- a/Netease-sync/server.js +++ b/Netease-sync/server.js @@ -771,6 +771,8 @@ async function syncPlaylist(playlist, cachedInfo = null) { const totalTracks = tracks.length; let syncedCount = 0; let failedCount = 0; + const downloadStatus = {}; + const unmatchedSongs = []; 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); await Promise.all(batch.map(async (song) => { try { - await processSong(song); + const ok = await processSong(song); + downloadStatus[song.id] = ok; } catch (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++; } else { 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% @@ -857,6 +868,14 @@ async function syncPlaylist(playlist, cachedInfo = null) { } 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 if (!playlist.navidromePlaylistId) {