Native Android client for Spotify, built with Jetpack Compose
Kotlin ad-freeadblockandroidjetpack-composekotlinlyricsmusic-playermusic-videomyspotispotifyspotify-adblockerspotify-clientspotify-connectspotui
Merge PR #165: extensions can romanize the lyrics shown, a lyrics-romanize hook
kota-zo5f94f469d74f
diff --cc base/app/src/main/java/com/music/spotui/data/api/LyricsApi.ktindex f854613b,63fe2323..5c55cf16--- 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@@@ -82,53 -73,26 +82,60 @@@ object LyricsApi/** How long a word-synced source is waited for before the line-synced ones answer instead. */private const val WORD_WAIT_MS = 4_000L- /** Lyrics to show while better ones are looked for (track key → Spotify's line-timed lyrics). */+ /**+ * The last lyrics shown while better ones are looked for (track key → the app's own lines); read+ * a song's own with [earlyFor]: the next song's prefetch publishes its own a moment later.+ */val early = kotlinx.coroutines.flow.MutableStateFlow<Pair<String, Lyrics>?>(null)+ private val earlyByKey = java.util.concurrent.ConcurrentHashMap<String, Lyrics>()++ /** What [track] can show while its lyrics are still looked for, or null. */+ fun earlyFor(track: Track): Lyrics? = earlyByKey[track.key]+ /** Lyrics of song [key] that got romanizations from an extension after they were shown: [before] became [after]. */+ data class Romanized(val key: String, val before: Lyrics, val after: Lyrics)++ /** The last [Romanized]: an open lyrics view still showing [Romanized.before] swaps it for [Romanized.after]. */+ val romanized = kotlinx.coroutines.flow.MutableStateFlow<Romanized?>(null)++- fun cached(track: Track): Lyrics? = cache[track.key] as? Lyrics+ private fun showEarly(track: Track, lyrics: Lyrics) {+ earlyByKey[track.key] = lyrics+ early.value = track.key to lyrics+ }++ fun cached(track: Track): Lyrics? = when (val c = cache[track.key]) {+ is Lyrics -> c+ is Partial -> c.lyrics+ else -> null+ }++ /** Whether [track]'s lyrics were found with every source's answer: nothing better is to come. */+ fun settled(track: Track): Boolean = cache[track.key] is Lyrics++ private fun wanted(track: Track): Boolean {+ if (track.title.isBlank() && track.trackId.isBlank()) return false+ return when (val c = cache[track.key]) {+ is Lyrics -> false+ is Miss -> System.currentTimeMillis() - c.at >= MISS_RETRY_MS+ is Partial -> System.currentTimeMillis() - c.at >= MISS_RETRY_MS+ else -> true+ }+ }++ // The song to warm once a song's lyrics are found ([prefetch]'s `then`), by that song's key.+ private val after = java.util.concurrent.ConcurrentHashMap<String, Track>()- /** Warm the cache in the background (current track and the next one). */- fun prefetch(track: Track) {- if (track.title.isBlank() && track.trackId.isBlank()) return- val c = cache[track.key]- if (c is Lyrics) return- if (c is Miss && System.currentTimeMillis() - c.at < MISS_RETRY_MS) return+ /**+ * Warm the cache in the background: [track] (the current one), then [then] (the next one) once+ * [track]'s are found. An extension answers one call at a time: the next song's asked together+ * with the playing one's went first at times, and the playing one's were cut short.+ */+ fun prefetch(track: Track, then: Track? = null) {+ if (!wanted(track)) { after.remove(track.key); then?.let { prefetch(it) }; return }+ if (then != null) after[track.key] = thenif (inFlight.containsKey(track.key)) return- scope.launch { runCatching { fetch(track) } }+ scope.launch { runCatching { fetch(track) }; after.remove(track.key)?.let { prefetch(it) } }}fun forget(track: Track) { cache.remove(track.key); health.forgetTrack(track.key); scope.launch { LyricsDisk.drop(track.key) } }@@@ -171,18 -123,11 +178,18 @@@// One request per track even when the card and the full screen ask together.val job = synchronized(inFlight) {inFlight[track.key] ?: scope.async(start = kotlinx.coroutines.CoroutineStart.LAZY) {- // Read on an earlier run: from storage, not asked for again.- (LyricsDisk.read(track.key)?.also { cache[track.key] = it } ?: resolve(track))?.also { romanizeLater(track, it) }+ // Read on an earlier run: from storage, not asked for again. A downloaded song's own+ // (see [keepForOffline]) when there is no connection, or when nothing else had any.- LyricsDisk.read(track.key)?.also { cache[track.key] = it }++ (LyricsDisk.read(track.key)?.also { cache[track.key] = it }+ ?: (if (online()) null else kept(track))+ ?: resolve(track)- ?: kept(track)++ ?: kept(track))?.also { romanizeLater(track, it) }}.also { created ->inFlight[track.key] = created- created.invokeOnCompletion { inFlight.remove(track.key, created) }+ created.invokeOnCompletion {+ inFlight.remove(track.key, created)+ after.remove(track.key)?.let { prefetch(it) }+ }created.start()}}@@@ -269,11 -215,33 +277,34 @@@chosen}+ /**+ * Asks the romanizing extensions, off the caller's path, for the lines of [lyrics] (just found+ * or read from storage) that their source left in another script than Latin without a+ * romanization: the lyrics show at once and the romanizations follow ([romanized]). They are+ * kept, in memory and storage, only while [lyrics] are still the song's.+ */+ private fun romanizeLater(track: Track, lyrics: Lyrics) {+ val wanted = LyricsRomanize.wanted(lyrics)+ if (wanted.isEmpty() || !runCatching { com.music.spotui.extensions.Extensions.hasRomanizer() }.getOrDefault(false)) return+ scope.launch {+ val found = runCatching {+ com.music.spotui.extensions.Extensions.romanizeFor(+ track.trackId, track.title, track.artist, track.album, track.durationMs, track.coverUrl, lyrics.language, wanted)+ }.getOrDefault(emptyMap())+ val updated = LyricsRomanize.apply(lyrics, found)+ if (updated === lyrics) return@launch+ // Another source picked or the song forgotten meanwhile: these were for lyrics no longer shown.+ if (!cache.replace(track.key, lyrics, updated)) return@launch+ LyricsDisk.write(track.key, updated)+ romanized.value = Romanized(track.key, lyrics, updated)+ }+ }+- private suspend fun resolve(track: Track): Lyrics? = coroutineScope {+ private suspend fun resolve(track: Track): Lyrics? = try { coroutineScope {// Extensions that provide lyrics are asked at the same time as the app's own sources// (each within its time limit); the better answer is kept (LyricsMerge), Spotify's own- // complete lyrics first at the same level, and then the extensions are not waited for.+ // complete lyrics first at the same level. Only when those have backing vocals too are+ // the extensions not waited for. A failure: they did not answer in time (null: none had lyrics).val ext = if (extensionsAsked()) async {runCatching {com.music.spotui.extensions.Extensions.lyricsFor(track.trackId, track.title, track.artist, track.album, track.durationMs, track.coverUrl)diff --cc base/app/src/main/java/com/music/spotui/extensions/ExtensionUi.ktindex 8e6a3a1a,092b4215..16177d8a--- a/base/app/src/main/java/com/music/spotui/extensions/ExtensionUi.kt+++ b/base/app/src/main/java/com/music/spotui/extensions/ExtensionUi.kt@@@ -24,8 -24,8 +24,9 @@@ import androidx.compose.material.icons.import androidx.compose.material.icons.automirrored.rounded.PlaylistPlayimport androidx.compose.material.icons.automirrored.rounded.QueueMusicimport androidx.compose.material.icons.automirrored.rounded.VolumeUp+ import androidx.compose.material.icons.rounded.Abcimport androidx.compose.material.icons.rounded.Add+import androidx.compose.material.icons.rounded.Paletteimport androidx.compose.material.icons.rounded.Albumimport androidx.compose.material.icons.rounded.BarChartimport androidx.compose.material.icons.rounded.Boltdiff --cc base/app/src/main/java/com/music/spotui/extensions/Extensions.ktindex faf55f06,5c60d4a7..03e48947--- a/base/app/src/main/java/com/music/spotui/extensions/Extensions.kt+++ b/base/app/src/main/java/com/music/spotui/extensions/Extensions.kt@@@ -96,14 -93,10 +97,16 @@@ object Extensions// Every hook's time is in [HookBudgets], shared with the desktop runner (`myspoti-ext`)./** A lyrics hook call. */const val LYRICS_MS = HookBudgets.LYRICS+ /** A lyrics-romanize hook call. */+ const val ROMANIZE_MS = HookBudgets.ROMANIZE/** An audio-source hook call. */const val AUDIO_MS = HookBudgets.AUDIO+ /**+ * An audio-source call for a song the user just picked: past it Spotify plays the song (seen:+ * a source whose server timed out held the tap silent 12 s, up to [AUDIO_MS]). The extension+ * is asked again for the next songs; one timing out several times in a row is set aside a while.+ */+ const val PICK_AUDIO_MS = 5_000L/** A download-source hook call (an extension may try several places). */const val DOWNLOAD_MS = HookBudgets.DOWNLOADprivate const val TRACK_MS = HookBudgets.TRACK@@@ -1707,19 -1571,18 +1739,26 @@@api.raw.request(method, url, body, headers).let { app.myspoti.extensions.RawRequest.response(it.status, it.headers, it.body) }}- /** Lyrics asked with a time limit of their own, for the app's lyrics resolver. */- suspend fun lyricsFor(trackId: String, title: String, artist: String, album: String, durationMs: Long, cover: String?): Lyrics? =- if (!hasLyrics()) null- else withTimeoutOrNull(LYRICS_MS + 1_000) { lyrics(trackInfo(trackId, title, artist, album, durationMs, cover)) }+ /**+ * Lyrics asked for the app's lyrics resolver. Each extension's time counts from when its call+ * runs, which may wait up to 30 s behind its earlier calls (ExtensionRuntime's queue: a song's+ * audio looked up, the next song's lyrics); counted from the request, its answer was cut short.+ * The limit here only ends a call past both, by an exception: the resolver then knows the+ * extensions did not answer in time, where null is that none had lyrics.+ */+ suspend fun lyricsFor(trackId: String, title: String, artist: String, album: String, durationMs: Long, cover: String?): Lyrics? {+ if (!hasLyrics()) return null+ val queueMs = 30_000L+ return kotlinx.coroutines.withTimeout(queueMs + 2 * LYRICS_MS + 1_000) { lyrics(trackInfo(trackId, title, artist, album, durationMs, cover)) }+ }+ /** [romanize] for the app's lyrics resolver: [lines] of the song's lyrics, in [language] when their source said it. */+ suspend fun romanizeFor(+ trackId: String, title: String, artist: String, album: String, durationMs: Long, cover: String?,+ language: String?, lines: Map<Int, String>,+ ): Map<Int, String> =+ if (!hasRomanizer()) emptyMap() else romanize(trackInfo(trackId, title, artist, album, durationMs, cover), language, lines)+/** The running extensions giving lyrics, in their order: (id, name). For the "Try another source" list. */fun lyricsSources(): List<Pair<String, String>> =if (!isReady) emptyList() else providing(Hook.LYRICS).map { (id, rt) -> id to rt.manifest.name }diff --cc base/extensions/src/main/resources/app/myspoti/extensions/prelude.jsindex 6de7ae24,78abc371..0fce34fb--- a/base/extensions/src/main/resources/app/myspoti/extensions/prelude.js+++ b/base/extensions/src/main/resources/app/myspoti/extensions/prelude.js@@@ -125,12 -123,12 +125,12 @@@/*** What this app understands beyond the first API, for an extension to adapt to: "audio.manifest",- * "audio.expires", "audio.quality", "audio.source", "audio.ahead", "http.all", "status", "raw.base64", "results" (source hooks may answer { outcome }), "settings.section" (manifest section, role, perNetwork), "util.sleep", "player.localMute" only when the user granted playback.mirror, and "attest" only when it granted attest.- * "audio.expires", "audio.quality", "audio.source", "audio.ahead", "http.all", "status", "raw.base64", "results" (source hooks may answer { outcome }), "settings.section" (manifest section, role, perNetwork), "lyrics.romanize" (the lyrics-romanize hook), "player.localMute" only when the user granted playback.mirror, and "attest" only when it granted attest.++ * "audio.expires", "audio.quality", "audio.source", "audio.ahead", "http.all", "status", "raw.base64", "results" (source hooks may answer { outcome }), "settings.section" (manifest section, role, perNetwork), "util.sleep", "lyrics.romanize" (the lyrics-romanize hook), "player.localMute" only when the user granted playback.mirror, and "attest" only when it granted attest.*/sources: Object.freeze({ race: function (hook, query, lanes) {return parse(host.sourceRace(String(hook),JSON.stringify(query),JSON.stringify(lanes)));} }),- features: Object.freeze(['audio.manifest', 'audio.expires', 'audio.quality', 'audio.source', 'audio.ahead', 'http.all', 'status', 'raw.base64', 'results', 'download.transform', 'audio.transform', 'sources.race', 'settings.section', 'util.sleep'].concat(parse(host.info()).mirror ? ['player.localMute'] : [], parse(host.info()).attest ? ['attest'] : [])),- features: Object.freeze(['audio.manifest', 'audio.expires', 'audio.quality', 'audio.source', 'audio.ahead', 'http.all', 'status', 'raw.base64', 'results', 'download.transform', 'audio.transform', 'sources.race', 'settings.section', 'lyrics.romanize'].concat(parse(host.info()).mirror ? ['player.localMute'] : [], parse(host.info()).attest ? ['attest'] : [])),++ features: Object.freeze(['audio.manifest', 'audio.expires', 'audio.quality', 'audio.source', 'audio.ahead', 'http.all', 'status', 'raw.base64', 'results', 'download.transform', 'audio.transform', 'sources.race', 'settings.section', 'util.sleep', 'lyrics.romanize'].concat(parse(host.info()).mirror ? ['player.localMute'] : [], parse(host.info()).attest ? ['attest'] : [])),/*** A sign-in page (webview.auth): open({ url, callback, hidden }) shows url in a web view of itsdiff --cc base/extensions/src/test/kotlin/app/myspoti/extensions/SandboxTest.ktindex ff77f09a,f6cfbfcf..462b21f5--- a/base/extensions/src/test/kotlin/app/myspoti/extensions/SandboxTest.kt+++ b/base/extensions/src/test/kotlin/app/myspoti/extensions/SandboxTest.kt@@@ -216,60 -199,7 +216,60 @@@ class SandboxTest}@Test fun featuresNameWhatThisAppUnderstands() {- assertEquals("""{"v":"audio.manifest,audio.expires,audio.quality,audio.source,audio.ahead,http.all,status,raw.base64,results,download.transform,audio.transform,sources.race,settings.section,util.sleep"}""", eval("return myspoti.features.join(',');"))- assertEquals("""{"v":"audio.manifest,audio.expires,audio.quality,audio.source,audio.ahead,http.all,status,raw.base64,results,download.transform,audio.transform,sources.race,settings.section,lyrics.romanize"}""", eval("return myspoti.features.join(',');"))++ assertEquals("""{"v":"audio.manifest,audio.expires,audio.quality,audio.source,audio.ahead,http.all,status,raw.base64,results,download.transform,audio.transform,sources.race,settings.section,util.sleep,lyrics.romanize"}""", eval("return myspoti.features.join(',');"))+ }++ @Test fun sleepCapsBackoffWithoutNeedingPermissions() {+ val host = FakeHost(sleeper = {})+ val out = eval("return [0, 1, 2000, 1000000000000].map(function (ms) { return typeof myspoti.util.sleep(ms); }).join(',');", host, granted = setOf("lyrics.provide"))+ assertEquals("""{"v":"undefined,undefined,undefined,undefined"}""", out)+ assertEquals(listOf(0L, 1L, 2000L, 2000L), host.sleeps)+ }++ @Test fun sleepRejectsInvalidDurationsBeforeCallingTheHost() {+ val host = FakeHost(sleeper = {})+ val out = eval("""+ return [-1, NaN, Infinity, 1.5, '5', null, undefined].every(function (ms) {+ try { myspoti.util.sleep(ms); return false; }+ catch (e) { return e instanceof TypeError && e.message.indexOf('util.sleep') >= 0; }+ });+ """, host)+ assertEquals("""{"v":true}""", out)+ assertTrue(host.sleeps.isEmpty())+ }++ @Test fun sleepCannotOverrunOrCatchTheHooksDeadline() {+ val host = FakeHost(sleeper = { fail("a wait beyond the deadline reached the host") })+ runtime("myspoti.provide('lyrics', function () { try { myspoti.util.sleep(2000); } catch (e) { return { plain: 'caught' }; } return { plain: 'done' }; });", host = host).use { rt ->+ try {+ rt.call(Hook.LYRICS, track.toJson(), 100)+ fail("a wait past the hook's deadline answered")+ } catch (e: ExtensionException) {+ assertTrue(e is ExtensionTimeout)+ }+ }+ assertTrue(host.sleeps.isEmpty())+ }++ @Test fun closeInterruptsSleepAndCannotBeSwallowedByTheScript() {+ val entered = java.util.concurrent.CountDownLatch(1)+ val host = FakeHost(sleeper = { millis -> entered.countDown(); Thread.sleep(millis) })+ val rt = runtime("myspoti.provide('lyrics', function () { try { myspoti.util.sleep(2000); } catch (e) { return { plain: 'caught' }; } return { plain: 'done' }; });", host = host)+ val result = java.util.concurrent.atomic.AtomicReference<Result<String?>>()+ val caller = Thread { result.set(runCatching { rt.call(Hook.LYRICS, track.toJson(), 5_000) }) }.apply { start() }+ try {+ assertTrue("sleep was never reached", entered.await(1, java.util.concurrent.TimeUnit.SECONDS))+ rt.close()+ caller.join(1_000)+ assertFalse("sleep ignored the runtime shutdown", caller.isAlive)+ val failure = result.get()?.exceptionOrNull()+ assertTrue(failure is ExtensionException)+ assertEquals("stopped", failure?.message)+ assertNull(rt.lastError)+ } finally {+ rt.close()+ caller.join(1_000)+ }}@Test fun localMuteFeatureIsListedOnlyWhenMirrorIsGranted() {diff --cc docs/extensions/API.mdindex 252bd766,21918d16..258d7f75--- a/docs/extensions/API.md+++ b/docs/extensions/API.md@@@ -126,7 -122,7 +126,7 @@@ extensions did there ("Lyrics of X fro| `replaces` | string[] | `[]` | Extension ids this one takes the place of (10 at most): installing it offers to turn them off. || `conflictsWith` | string[] | `[]` | Extension ids that must not run with this one (10 at most): the user picks which to keep. Either side declaring it is enough. || `icon` | string | none | A `.png` at the root of the package (square, 256 px or less). Without it, `icon.png` is used if the package has one, else a tile with the name's first letter. |- | `category` | string | `other` | Where the store files it, one of a fixed list: `lyrics` (needs `lyrics.provide` or `trackinfo.provide`), `playback` (Playback & audio: a `playback.*`, `audio.source` or `player.buttons` action), `library` (`library.read`, `library.write` or `playlists.write`), `discovery` (`home.sections`, `search.provide` or `spotify.catalog`), `stats` (`playback.events` or `library.read`), `look` (Look & feel: a blocks action, `webview.page` or `ui.style`), `social` (`network`, `library.read` or `spotify.catalog`), `tools`, `other`. A category the actions do not fit, or an unknown one, is filed under `other` (`myspoti-ext check` says so); an extension with `download.source` is always under `tools`. `tags` are shown and found by the search, not filtered on. |-| `category` | string | `other` | Where the store files it, one of a fixed list: `lyrics` (needs `lyrics.provide`, `lyrics.romanize` or `trackinfo.provide`), `playback` (Playback & audio: a `playback.*`, `audio.source` or `player.buttons` action), `library` (`library.read`, `library.write` or `playlists.write`), `discovery` (`home.sections`, `search.provide` or `spotify.catalog`), `stats` (`playback.events` or `library.read`), `look` (Look & feel: a blocks action or `webview.page`), `social` (`network`, `library.read` or `spotify.catalog`), `tools`, `other`. A category the actions do not fit, or an unknown one, is filed under `other` (`myspoti-ext check` says so); an extension with `download.source` is always under `tools`. `tags` are shown and found by the search, not filtered on. |++| `category` | string | `other` | Where the store files it, one of a fixed list: `lyrics` (needs `lyrics.provide`, `lyrics.romanize` or `trackinfo.provide`), `playback` (Playback & audio: a `playback.*`, `audio.source` or `player.buttons` action), `library` (`library.read`, `library.write` or `playlists.write`), `discovery` (`home.sections`, `search.provide` or `spotify.catalog`), `stats` (`playback.events` or `library.read`), `look` (Look & feel: a blocks action, `webview.page` or `ui.style`), `social` (`network`, `library.read` or `spotify.catalog`), `tools`, `other`. A category the actions do not fit, or an unknown one, is filed under `other` (`myspoti-ext check` says so); an extension with `download.source` is always under `tools`. `tags` are shown and found by the search, not filtered on. || `tags` | string[] | `[]` | 8 at most, each 1 to 24 characters: lower case letters, digits, spaces, `-`. The store's search finds them. || `minAppVersion` | string | none | The oldest Myspoti it works on (`"2.0.2"`, `"2.0.2-beta.4"`), compared like semantic versions (a release is newer than its betas). An older Myspoti shows "Requires Myspoti 2.0.2 or newer" and does not install it. || `changelog` | string | `""` | What changed in this version, 2000 characters at most: shown on the store page and before an update. |@@@ -285,9 -253,10 +286,10 @@@ player.buttons action in the manifest`)| `tap` | any blocks action | `{ action, surface, context }` | nothing (the app asks the blocks again) || `status` | none | `{}` | `{ live, detail? }` (below) |- The lyrics, song details, Home, search, menu and player hooks are **additive**: every extension is- asked, the answers merged in the area's order (lyrics: the best, ties to the higher one). Audio and+ The lyrics, romanization, song details, Home, search, menu and player hooks are **additive**: every extension is+ asked, the answers merged in the area's order (lyrics: the best, ties to the higher one;+ romanizations: each extension is sent the lines the ones before it left without one). Audio and-downloads are **ordered**: asked one after the other in the user's order until one answers (section 4.2). Registering twice replaces. Returning+downloads are **ordered**: asked one after the other in the user's order until one answers (section 4.2); for downloads the file that fits the quality best goes first (`download-source` below). Registering twice replaces. Returning`null`/`undefined` means "no answer": the app goes on without this extension. A throw is afailure (recorded as the extension's last error, shown on its page; 3 in a row turn it off). Atimeout, or an `http` error your script did not catch (DNS, connection, timeout), is a **network**@@@ -829,9 -828,8 +866,9 @@@ A script that throws while loading fail| Call | Notes ||---|---|| `myspoti.apiVersion` | `1`. |+| `myspoti.locale` | The language Myspoti shows, as a BCP 47 tag: `"fr"`, `"pt-BR"`, `"zh-TW"`. Below. || `myspoti.extension` | `{ id, name, version }` from the manifest. |- | `myspoti.features` | What this Myspoti understands beyond the first API: `audio.manifest`, `audio.expires`, `audio.quality`, `audio.ahead` (section 3, `audio-source`), `http.all`, `status` (section 3), `results` (section 3, "Outcomes"), `settings.section` (section 2: a setting's `section`, `role`, `perNetwork`), `util.sleep`, `attest` (section 10, only when the user granted it). Missing on an older Myspoti: test `myspoti.features && myspoti.features.indexOf(name) >= 0`. |-| `myspoti.features` | What this Myspoti understands beyond the first API: `audio.manifest`, `audio.expires`, `audio.quality`, `audio.ahead` (section 3, `audio-source`), `http.all`, `status` (section 3), `results` (section 3, "Outcomes"), `settings.section` (section 2: a setting's `section`, `role`, `perNetwork`), `lyrics.romanize` (section 3, `lyrics-romanize`), `attest` (section 10, only when the user granted it). Missing on an older Myspoti: test `myspoti.features && myspoti.features.indexOf(name) >= 0`. |++| `myspoti.features` | What this Myspoti understands beyond the first API: `audio.manifest`, `audio.expires`, `audio.quality`, `audio.ahead` (section 3, `audio-source`), `http.all`, `status` (section 3), `results` (section 3, "Outcomes"), `settings.section` (section 2: a setting's `section`, `role`, `perNetwork`), `util.sleep`, `lyrics.romanize` (section 3, `lyrics-romanize`), `attest` (section 10, only when the user granted it). Missing on an older Myspoti: test `myspoti.features && myspoti.features.indexOf(name) >= 0`. || `myspoti.provide(hook, fn)` | Section 3. || `myspoti.on('track' \| 'playback', fn)` | Section 3. Needs `playback.events`. || `myspoti.on('auth', fn)` | Section 3, sign in. Needs `webview.auth`. |