feat: add NetEase as lyrics fallback after lrclib (Android + web)
Search order: lrclib exact → lrclib fuzzy search → NetEase. NetEase has strong coverage for Asian/Japanese music that lrclib misses. Duration-matched candidate selection on all three steps. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
8b9bfd3098
commit
71667d1a03
2 files changed
+102
-15
No files matched your search
@@ -183,6 +183,39 @@ async function _loadNpLyrics(songId) {
|
||||
} catch {}
|
||||
}
|
||||
|
||||
// 3. NetEase fallback — good coverage for Asian/Japanese music
|
||||
if(token !== _lyricsLoadToken) return;
|
||||
if(!result?.syncedLyrics && !result?.plainLyrics) {
|
||||
try {
|
||||
const q = encodeURIComponent(`${artist} ${title}`.trim());
|
||||
const sr = await fetch(`https://music.163.com/api/search/get?s=${q}&type=1&limit=5`, {
|
||||
headers: { Referer: 'https://music.163.com' },
|
||||
signal: AbortSignal.timeout(8000),
|
||||
});
|
||||
if(sr.ok) {
|
||||
const sd = await sr.json();
|
||||
const songs = sd?.result?.songs || [];
|
||||
const durMs = dur * 1000;
|
||||
const song = dur
|
||||
? songs.sort((a, b) => Math.abs(a.duration - durMs) - Math.abs(b.duration - durMs))
|
||||
.find(s => Math.abs(s.duration - durMs) <= 5000)
|
||||
: songs[0];
|
||||
if(song) {
|
||||
if(token !== _lyricsLoadToken) return;
|
||||
const lr = await fetch(
|
||||
`https://music.163.com/api/song/lyric?id=${song.id}&lv=1&kv=1&tv=-1`,
|
||||
{ headers: { Referer: 'https://music.163.com' }, signal: AbortSignal.timeout(8000) },
|
||||
);
|
||||
if(lr.ok) {
|
||||
const ld = await lr.json();
|
||||
const lrc = ld?.lrc?.lyric;
|
||||
if(lrc) result = { syncedLyrics: lrc };
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
|
||||
if(token !== _lyricsLoadToken) return;
|
||||
content.innerHTML = '';
|
||||
|
||||
|
||||
Reference in new issue
Block a user