From 0272b9e99fddd81c0eaae0ef4f7a32af92d4af61 Mon Sep 17 00:00:00 2001 From: Honey Date: Mon, 15 Jun 2026 21:48:46 +0200 Subject: [PATCH] chore: remove NetEase lyrics fallback from Android and web NetEase returned wrong/unsynced results. lrclib with exact + fuzzy search is sufficient; no third-party Chinese platform needed. Co-Authored-By: Claude Sonnet 4.6 --- .../com/novasonic/app/api/LrcLibClient.kt | 46 +------------------ src/player/nowplaying.js | 24 ---------- 2 files changed, 2 insertions(+), 68 deletions(-) diff --git a/android/app/src/main/kotlin/com/novasonic/app/api/LrcLibClient.kt b/android/app/src/main/kotlin/com/novasonic/app/api/LrcLibClient.kt index 79f7b4c..60d8457 100644 --- a/android/app/src/main/kotlin/com/novasonic/app/api/LrcLibClient.kt +++ b/android/app/src/main/kotlin/com/novasonic/app/api/LrcLibClient.kt @@ -10,7 +10,6 @@ import io.ktor.http.* import io.ktor.serialization.kotlinx.json.* import kotlinx.coroutines.async import kotlinx.coroutines.coroutineScope -import kotlinx.coroutines.withTimeoutOrNull import kotlinx.serialization.Serializable import kotlinx.serialization.json.Json @@ -26,16 +25,6 @@ data class LrcLibResponse( val syncedLyrics: String? = null, ) -@Serializable -private data class NetEaseSearchResp(val result: NetEaseResult? = null, val code: Int = 0) -@Serializable -private data class NetEaseResult(val songs: List = emptyList()) -@Serializable -private data class NetEaseSong(val id: Long = 0, val duration: Long = 0) -@Serializable -private data class NetEaseLyricsResp(val lrc: NetEaseLrc? = null, val code: Int = 0) -@Serializable -private data class NetEaseLrc(val lyric: String? = null) data class LrcLine(val timeMs: Long, val text: String) @@ -115,15 +104,8 @@ object LrcLibClient { ?: bestMatch(titleDef.await(), durationSecs) } - if (lrclibResult != null) return lrclibResult.also { cache[cacheKey] = it } - - // 4. NetEase fallback - val neLrc = withTimeoutOrNull(8_000) { - runCatching { netEaseLyrics(artist, title, durationSecs) }.getOrNull() - } - val result = if (!neLrc.isNullOrBlank()) LrcLibResponse(syncedLyrics = neLrc) else null - cache[cacheKey] = result - return result + cache[cacheKey] = lrclibResult + return lrclibResult } private fun LrcLibResponse?.hasContent() = @@ -142,28 +124,4 @@ object LrcLibClient { } } - private suspend fun netEaseLyrics(artist: String, title: String, durationSecs: Int?): String? { - val search = client.get("https://music.163.com/api/search/get") { - parameter("s", "$artist $title".trim()) - parameter("type", 1) - parameter("limit", 5) - header("Referer", "https://music.163.com") - }.body() - - val songs = search.result?.songs ?: return null - val song = if (durationSecs != null && durationSecs > 0) { - val durMs = durationSecs * 1000L - songs.minByOrNull { kotlin.math.abs(it.duration - durMs) } - ?.takeIf { kotlin.math.abs(it.duration - durMs) <= 5000L } - ?: songs.firstOrNull() - } else songs.firstOrNull() ?: return null - - return client.get("https://music.163.com/api/song/lyric") { - parameter("id", song!!.id) - parameter("lv", 1) - parameter("kv", 1) - parameter("tv", -1) - header("Referer", "https://music.163.com") - }.body().lrc?.lyric?.takeIf { it.isNotBlank() } - } } diff --git a/src/player/nowplaying.js b/src/player/nowplaying.js index 0ff1361..0b10044 100644 --- a/src/player/nowplaying.js +++ b/src/player/nowplaying.js @@ -204,30 +204,6 @@ async function _loadNpLyrics(songId) { if(token !== _lyricsLoadToken) return; - // NetEase fallback — good for Asian/Japanese music - if(!result?.syncedLyrics && !result?.plainLyrics) { - try { - const q = encodeURIComponent(`${artist} ${title}`.trim()); - const sd = await safeJson(fetch(`https://music.163.com/api/search/get?s=${q}&type=1&limit=5`, { - headers: { Referer: 'https://music.163.com' }, signal: SIG(), - })); - 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 && token === _lyricsLoadToken) { - const ld = await safeJson(fetch( - `https://music.163.com/api/song/lyric?id=${song.id}&lv=1&kv=1&tv=-1`, - { headers: { Referer: 'https://music.163.com' }, signal: SIG() }, - )); - const lrc = ld?.lrc?.lyric; - if(lrc) result = { syncedLyrics: lrc }; - } - } catch {} - } - if(token !== _lyricsLoadToken) return; _lyricsCache.set(cacheKey, result ?? null); content.innerHTML = '';