Skip to content

Native Android client for Spotify, built with Jetpack Compose

Lyrics: drop the Apple Music source (mirrors unreliable)

kota-zoe2c7966ec1fd
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 25451e73..81a2c9af 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,7 +8,6 @@ Each release on GitHub shows its section below. The app shows it too when it off
- **Steadier player**: play, pause and skips go one at a time (fast taps no longer jam it), and a song that did not start is asked again.
- **No more "pop" between songs**: a very short fade on every skip.
- **Smart shuffle from the player**: tap shuffle twice on a playlist or Liked Songs.
-- **Word-by-word lyrics from Apple Music** when they exist, replacing line-by-line ones as soon as they arrive.
- **Remote control**: with another device playing, the notification and the slider keep up.
- **Sleep timer "end of track"** works with episodes, local files and repeat one; artist pages load the whole discography.
- **Artist discography** (Releases) shows albums and singles again.
diff --git a/base/app/src/main/java/com/music/spotui/data/api/LyricsApi.kt b/base/app/src/main/java/com/music/spotui/data/api/LyricsApi.kt
index e366d46e..a6bfea3f 100644
--- a/base/app/src/main/java/com/music/spotui/data/api/LyricsApi.kt
+++ b/base/app/src/main/java/com/music/spotui/data/api/LyricsApi.kt
@@ -21,9 +21,6 @@ import java.net.URLEncoder
* 1. Spotify's own color-lyrics, by track id: exactly what the official app shows,
* with its colours and credits.
* 2. LRCLIB (lrclib.net, open API for third-party apps), line-synced or plain.
- * Apple Music's word-synced lyrics (LyricsPlus mirrors) are always asked too: Spotify's
- * lyrics show at once, and are swapped for Apple's word-by-word ones when those arrive
- * ([upgrades]), since they follow every word.
* 3. Opt-in ("sources supplémentaires"): NetEase Cloud Music (line-synced LRC) and
* Genius (plain text). Off by default.
*
@@ -33,10 +30,6 @@ import java.net.URLEncoder
object LyricsApi {
private const val LRCLIB = "https://lrclib.net/api"
private const val UA = "Myspoti (https://github.com/)"
- private val LYRICSPLUS = listOf(
- "https://lyricsplus.binimum.org",
- "https://lyricsplus.prjktla.my.id",
- )
/** What the resolver needs to know about a track. */
data class Track(
@@ -63,19 +56,6 @@ object LyricsApi {
/** Set by the settings: also ask NetEase and Genius when nothing better is found. */
@Volatile var extraSources: Boolean = false
- /** Word-synced lyrics that replaced a track's first ones after the fact (track key, lyrics). */
- val upgrades = kotlinx.coroutines.flow.MutableSharedFlow<Pair<String, Lyrics>>(extraBufferCapacity = 8)
-
- /** Looks for Apple's word-synced lyrics behind line-synced ones; a better result replaces them. */
- private fun upgradeLater(track: Track, first: Lyrics) {
- if (first.wordSynced) return
- scope.launch {
- val apple = runCatching { fromLyricsPlus(cleanTitle(track.title), track.artist.substringBefore(",").trim(), (track.durationMs / 1000).toInt()) }.getOrNull()
- if (apple == null || !apple.wordSynced || apple.isEmpty) return@launch
- cache[track.key] = apple
- upgrades.tryEmit(track.key to apple)
- }
- }
fun cached(track: Track): Lyrics? = cache[track.key] as? Lyrics
@@ -111,28 +91,22 @@ object LyricsApi {
}
private suspend fun resolve(track: Track): Lyrics? {
- val spotify = fromSpotify(track)
- if (spotify != null) upgradeLater(track, spotify)
- val result = spotify ?: coroutineScope {
+ val result = fromSpotify(track) ?: coroutineScope {
val title = cleanTitle(track.title)
val artist = track.artist.substringBefore(",").trim()
val durationSec = (track.durationMs / 1000).toInt()
- val extra = async { fromLyricsPlus(title, artist, durationSec) }
val netease = if (extraSources) async { fromNetEase(title, artist, durationSec) } else null
val genius = if (extraSources) async { fromGenius(title, artist) } else null
val exact = async { lrclibGet(title, artist, track.album, durationSec) }
val fuzzy = async { lrclibSearch("$LRCLIB/search?track_name=${enc(title)}&artist_name=${enc(artist)}", title, artist, durationSec) }
val lrclib = exact.await() ?: fuzzy.await()
?: lrclibSearch("$LRCLIB/search?track_name=${enc(title)}", title, artist, durationSec)
- val word = extra.await()
val ne = netease?.await()
- // Word-synced beats line-synced beats plain.
+ // Synced beats plain.
when {
- word != null && word.wordSynced -> word
lrclib != null && lrclib.synced -> lrclib
- word != null && word.synced -> word
ne != null && ne.synced -> ne
- else -> lrclib ?: word ?: ne ?: genius?.await()
+ else -> lrclib ?: ne ?: genius?.await()
}
}
cache[track.key] = result ?: Miss()
@@ -260,45 +234,6 @@ object LyricsApi {
return Lyrics(plain.split("\n").map { LyricLine(0L, it) }, synced = false, provider = "LRCLIB")
}
- // ── 3. LyricsPlus (Apple Music TTML as JSON, word / syllable timing) ──
- private fun fromLyricsPlus(title: String, artist: String, durationSec: Int): Lyrics? {
- for (server in LYRICSPLUS) {
- val url = "$server/v2/lyrics/get?title=${enc(title)}&artist=${enc(artist)}" +
- (if (durationSec > 0) "&duration=$durationSec" else "")
- // The mirror asks Apple then its other sources: a slow answer is still worth it.
- val o = httpGet(url, timeoutMs = 12_000)?.let { runCatching { JSONObject(it) }.getOrNull() } ?: continue
- val meta = o.optJSONObject("metadata")
- val gotTitle = meta?.optString("title").orEmpty().ifBlank { o.optString("trackName") }
- if (gotTitle.isNotBlank() && !overlaps(matchKey(cleanTitle(gotTitle)), matchKey(title))) continue
- val arr = o.optJSONArray("lyrics") ?: continue
- val lines = ArrayList<LyricLine>()
- for (i in 0 until arr.length()) {
- val l = arr.optJSONObject(i) ?: continue
- val syl = l.optJSONArray("syllabus")
- val words = if (syl != null && syl.length() > 0) {
- (0 until syl.length()).mapNotNull { j ->
- val w = syl.optJSONObject(j) ?: return@mapNotNull null
- if (w.optBoolean("isBackground")) return@mapNotNull null
- val t = w.optLong("time")
- LyricWord(t, t + w.optLong("duration"), w.optString("text"))
- }.takeIf { it.isNotEmpty() }
- } else null
- val text = words?.joinToString("") { it.text }?.trim() ?: l.optString("text").trim()
- if (text.isEmpty()) continue
- lines.add(LyricLine(l.optLong("time"), text, words))
- }
- if (lines.isEmpty()) continue
- val synced = o.optString("type") != "plain" && lines.any { it.timeMs > 0 }
- return Lyrics(
- lines = lines,
- synced = synced,
- language = meta?.optString("language")?.takeIf { it.isNotBlank() },
- provider = "Apple Music (LyricsPlus)",
- )
- }
- return null
- }
-
// ── Matching ──
// Strip the noise Spotify puts in titles that other catalogues don't have:
// "Song - 2011 Remaster", "Song (feat. X)", "Song [Bonus Track]".
diff --git a/base/app/src/main/java/com/music/spotui/data/preferences/SettingsPref.kt b/base/app/src/main/java/com/music/spotui/data/preferences/SettingsPref.kt
index bf709458..1e675890 100644
--- a/base/app/src/main/java/com/music/spotui/data/preferences/SettingsPref.kt
+++ b/base/app/src/main/java/com/music/spotui/data/preferences/SettingsPref.kt
@@ -12,7 +12,7 @@ private const val KEY_LIBRARY_GRID = "library_grid_view"
private const val KEY_LYRIC_TRANSLATE_LANG = "lyric_translate_lang"
private const val KEY_LYRICS_EXTRA = "lyrics_extra_sources"
-/** Word-synced lyrics from third-party Apple Music mirrors (LyricsPlus). Off by default. */
+/** Extra lyrics sources (NetEase, Genius) when Spotify and LRCLIB have none. Off by default. */
fun isLyricsExtraSources(c: Context): Boolean = prefs(c).getBoolean(KEY_LYRICS_EXTRA, false)
fun setLyricsExtraSources(c: Context, v: Boolean) = prefs(c).edit().putBoolean(KEY_LYRICS_EXTRA, v).apply()
diff --git a/base/app/src/main/java/com/music/spotui/ui/viewmodel/LyricsViewModel.kt b/base/app/src/main/java/com/music/spotui/ui/viewmodel/LyricsViewModel.kt
index a3e453eb..6ec951c2 100644
--- a/base/app/src/main/java/com/music/spotui/ui/viewmodel/LyricsViewModel.kt
+++ b/base/app/src/main/java/com/music/spotui/ui/viewmodel/LyricsViewModel.kt
@@ -33,15 +33,6 @@ class LyricsViewModel constructor() : ViewModel() {
private var loadedKey: String? = null
- init {
- // Apple's word-by-word lyrics came after the first ones: shown in their place.
- viewModelScope.launch {
- LyricsApi.upgrades.collect { (key, lyrics) ->
- if (key == loadedKey && _state.value !is State.Loading) _state.value = loadedState(lyrics)
- }
- }
- }
-
fun load(track: LyricsApi.Track, force: Boolean = false) {
val key = track.key
if (!force && loadedKey == key && _state.value !is State.NotFound) return
diff --git a/base/app/src/main/res/values-fr/myspoti_strings.xml b/base/app/src/main/res/values-fr/myspoti_strings.xml
index a7f8c0a4..57812002 100644
--- a/base/app/src/main/res/values-fr/myspoti_strings.xml
+++ b/base/app/src/main/res/values-fr/myspoti_strings.xml
@@ -32,7 +32,7 @@
<string name="verified_artist">Artiste vérifié</string>
<string name="lyrics_share">Partager des paroles</string>
<string name="lyrics_extra_title">Plus de sources de paroles</string>
- <string name="lyrics_extra_summary">NetEase et Genius, quand ni Spotify ni Apple Music n\'ont les paroles</string>
+ <string name="lyrics_extra_summary">NetEase et Genius, quand Spotify n\'a pas les paroles</string>
<string name="lyrics_reload">Recharger les paroles</string>
<string name="lyrics_fullscreen">Ouvrir les paroles en plein écran</string>
<string name="browse_all">Parcourir tout</string>
diff --git a/base/app/src/main/res/values-it/myspoti_strings.xml b/base/app/src/main/res/values-it/myspoti_strings.xml
index 71f6f38e..fbd91e4c 100644
--- a/base/app/src/main/res/values-it/myspoti_strings.xml
+++ b/base/app/src/main/res/values-it/myspoti_strings.xml
@@ -32,7 +32,7 @@
<string name="verified_artist">Artista verificato</string>
<string name="lyrics_share">Condividi il testo</string>
<string name="lyrics_extra_title">Altre fonti per i testi</string>
- <string name="lyrics_extra_summary">NetEase e Genius, quando né Spotify né Apple Music hanno il testo</string>
+ <string name="lyrics_extra_summary">NetEase e Genius, quando Spotify non ha il testo</string>
<string name="lyrics_reload">Ricarica il testo</string>
<string name="lyrics_fullscreen">Apri il testo a schermo intero</string>
<string name="browse_all">Sfoglia tutto</string>
diff --git a/base/app/src/main/res/values/myspoti_strings.xml b/base/app/src/main/res/values/myspoti_strings.xml
index 09568ad2..6d4d4a17 100644
--- a/base/app/src/main/res/values/myspoti_strings.xml
+++ b/base/app/src/main/res/values/myspoti_strings.xml
@@ -32,7 +32,7 @@
<string name="verified_artist">Verified Artist</string>
<string name="lyrics_share">Share lyrics</string>
<string name="lyrics_extra_title">More lyrics sources</string>
- <string name="lyrics_extra_summary">NetEase and Genius, when neither Spotify nor Apple Music has the lyrics</string>
+ <string name="lyrics_extra_summary">NetEase and Genius, when Spotify has no lyrics</string>
<string name="lyrics_reload">Reload lyrics</string>
<string name="lyrics_fullscreen">Open lyrics full screen</string>
<string name="browse_all">Browse all</string>
diff --git a/docs/CHANGELOG-full.md b/docs/CHANGELOG-full.md
index 698ad1fd..10815aec 100644
--- a/docs/CHANGELOG-full.md
+++ b/docs/CHANGELOG-full.md
@@ -9,7 +9,6 @@ Every change, release by release. The short version is in [CHANGELOG.md](../CHAN
- **Transport commands** (play, pause, next, previous, skip to) run one at a time and only the newest counts; a play is checked against the page's state and sent once more when it did not take (the old song kept playing).
- **Fades**: every skip or play lowers the sound over ~0.1 s and brings it back once the next song plays (always within 4 s): the "pop" heard in the phone's speaker is gone. Ads and user volume changes are taken into account.
- **Smart shuffle in the player**: the shuffle button goes off → shuffle → smart shuffle on playlists and Liked Songs; the smart mix is shared with the playlist page.
-- **Lyrics**: Apple Music's word-synced lyrics (LyricsPlus) are always looked up; Spotify's show first and are replaced when Apple's arrive. The dead LyricsPlus mirror is gone; the "more sources" setting now covers NetEase and Genius.
- **Remote control (#40)**: while another device plays, the state is read every 3 s.
- **Sleep timer "end of track"**: based on the media uri and the clock, so episodes, local files and repeat one stop too.
- **Artist pages** load every page of the discography (up to 300 releases).