Native Android client for Spotify, built with Jetpack Compose
Kotlin ad-freeadblockandroidjetpack-composekotlinlyricsmusic-playermusic-videomyspotispotifyspotify-adblockerspotify-clientspotify-connectspotui
Licences refused (#134): every diagnostic of it came from a phone on Widevine 15.0 or 16.0, refused from its first song before any ad, free accounts that play on newer phones alike: the ads are blocked again as before (letting them play muted cleared nothing), and on such a phone the message says the phone's DRM is too old for Spotify's web player and that an audio-source extension can play the songs; an ad on another Connect device is still never got past from here, and a held ad is logged once
kota-zo142e753333c5
diff --git a/base/api-spotify/src/main/kotlin/app/myspoti/spotify/LicenceRefusals.kt b/base/api-spotify/src/main/kotlin/app/myspoti/spotify/LicenceRefusals.ktindex d3d18a69..206436c0 100644--- a/base/api-spotify/src/main/kotlin/app/myspoti/spotify/LicenceRefusals.kt+++ b/base/api-spotify/src/main/kotlin/app/myspoti/spotify/LicenceRefusals.kt@@ -6,10 +6,6 @@ package app.myspoti.spotify* the page moved on by itself to the next one a fraction of a second later, through the list.* One refusal is a song that cannot play here (a market); [limit] within [windowMs] is the account.* Only observed: the request and its answer are Spotify's, nothing is answered in their place.- * In #134 and the four diagnostics of 26/10 to 30/10 not one song's licence was granted, the first- * refused before any ad or reload of the session: what this app does to ads within the session is- * not what starts it. What clears it is not known; ads queued meanwhile are let play, muted- * ([app.myspoti.spotify.bridge.AdBlock.adsOwed]), and the first licence granted ends it all.*/internal class LicenceRefusals(private val limit: Int = 3, private val windowMs: Long = 10_000) {private val times = ArrayDeque<Long>()@@ -26,13 +22,5 @@ internal class LicenceRefusals(private val limit: Int = 3, private val windowMs:companion object {/** A song's licence, not the Widevine certificate (both are under `widevine-license`). */fun isAudio(url: String): Boolean = "widevine-license" in url && "/audio/license" in url-- /**- * Whether an ad that plays is let play (muted) to its end instead of got past (a reload, a- * play of the next song): only while ads are owed ([app.myspoti.spotify.bridge.AdBlock.adsOwed]),- * not on a page that only mirrors an extension's song (it is reloaded as before), and not an- * ad whose file did not load ([refused]: it never ends by itself).- */- fun letAdPlay(owed: Boolean, mirroring: Boolean, refused: Boolean): Boolean = owed && !mirroring && !refused}}diff --git a/base/api-spotify/src/main/kotlin/app/myspoti/spotify/SpotifyPlayer.kt b/base/api-spotify/src/main/kotlin/app/myspoti/spotify/SpotifyPlayer.ktindex 63ada07a..077d6af1 100644--- a/base/api-spotify/src/main/kotlin/app/myspoti/spotify/SpotifyPlayer.kt+++ b/base/api-spotify/src/main/kotlin/app/myspoti/spotify/SpotifyPlayer.kt@@ -212,8 +212,6 @@ class SpotifyPlayer(private val bridge: Bridge, private val scope: CoroutineScopval s = _state.valueif (pageLicences++ < PAGE_LICENCES_LOGGED)bridge.logger?.invoke("page licence #$pageLicences: $status ${url.substringAfter("widevine-license", url).take(60)} on ${s?.item?.uri ?: "nothing"}, ${if (pageReadyAt > 0) "${now - pageReadyAt} ms after ready" else "page not ready"}")- // A song's licence granted while ads were owed: Spotify plays this account again.- if (status in 200..299 && LicenceRefusals.isAudio(url)) { licencesGranted(); return }if (status != 403 || !LicenceRefusals.isAudio(url)) return// The page only mirrors a song of an extension, heard from the phone's own player: its// licences are not what the user hears. Nor are another device's.@@ -231,29 +229,6 @@ class SpotifyPlayer(private val bridge: Bridge, private val scope: CoroutineScopbridge.logger?.invoke("Spotify refuses this account's audio licences ($why): paused, no reload nor replay until the next play")_licencesRefused.tryEmit(Unit)scope.launch { runCatching { pause() } }- adsOwed(true)- }-- /**- * Ads owed (see [app.myspoti.spotify.bridge.AdBlock.adsOwed]): on from the refusal until a- * song's licence is granted again. Every report of the refusal had no licence granted at all- * and the one ad Spotify queued refused by the app; the ads it queues now play, muted.- */- private fun adsOwed(on: Boolean) {- if (app.myspoti.spotify.bridge.AdBlock.adsOwed == on) return- app.myspoti.spotify.bridge.AdBlock.adsOwed = on- bridge.logger?.invoke(if (on) "ads let through and played muted until Spotify grants a licence again" else "ads blocked again: Spotify grants this account's licences")- scope.launch { runCatching { bridge.call("ads.owed", buildJsonObject { put("on", on) }) } }- }-- /** A song's licence granted (200): a refusal before it is over, its hold and its ads owed too. */- private fun licencesGranted() {- if (!app.myspoti.spotify.bridge.AdBlock.adsOwed && !licenceRefusedHold) return- if (licenceRefusedHold) {- licenceRefusedHold = false- bridge.logger?.invoke("a licence granted again: repairs back on")- }- adsOwed(false)}/** The user plays (a pick, a skip, play): repairs may run again. */@@ -666,9 +641,8 @@ class SpotifyPlayer(private val bridge: Bridge, private val scope: CoroutineScopvar attempts = 0var adAttempts = 0var adReloaded = false- /** This break was said once in the log: on another device, let play (ads owed), left as it is (held). */+ /** This break was said once in the log: on another device, left as it is (held). */var remoteAdLogged = false- var adOwedLogged = falsevar adHeldLogged = falsevar frozenReloadAt = 0L/** Consecutive ticks where the page answered nothing (see FROZEN_MISSES). */@@ -744,7 +718,7 @@ class SpotifyPlayer(private val bridge: Bridge, private val scope: CoroutineScoptickCrossfade(s, media, now)if (localMuted && s?.item?.uri != hushedUri) { hushedUri = s?.item?.uri; applyHush() }if (tick % VOLUME_CHECK_TICKS == 0) guardVolume(s, media)- if (!_adPlaying.value) { remoteAdLogged = false; adOwedLogged = false; adHeldLogged = false }+ if (!_adPlaying.value) { remoteAdLogged = false; adHeldLogged = false }if (_adPlaying.value && remoteActive) {// The ad plays on another device of the account (Connect, Cast): muted there by the// app (RemoteAdMute), never got past from here. A reload or a play of the next song@@ -778,12 +752,10 @@ class SpotifyPlayer(private val bridge: Bridge, private val scope: CoroutineScop// next song, so nothing clears the ad flag and the phone stays silent for good// (reported as "no sound until the app is restarted"). The sound comes back// anyway, and the state is read again.- // Ads owed play to their end, a whole break of them (several ads) muted.- val muteMax = if (app.myspoti.spotify.bridge.AdBlock.adsOwed) AD_BREAK_MAX_MS else AD_MUTE_MAX_MS- if (adMutedAt > 0 && now - adMutedAt > muteMax) {- bridge.logger?.invoke("ad mute older than ${muteMax / 1000}s: unmuted")+ if (adMutedAt > 0 && now - adMutedAt > AD_MUTE_MAX_MS) {+ bridge.logger?.invoke("ad mute older than ${AD_MUTE_MAX_MS / 1000}s: unmuted")runCatching { unmuteAfterAd() }- if (adStateAt > 0 && now - adStateAt > muteMax) {+ if (adStateAt > 0 && now - adStateAt > AD_MUTE_MAX_MS) {adState = null; adStateAt = 0LadAttempts = 0; adReloaded = false; adsOffSent = false_adPlaying.value = false@@ -808,21 +780,12 @@ class SpotifyPlayer(private val bridge: Bridge, private val scope: CoroutineScop}}// A refused ad sits at 0:00, buffering; a real one plays to its end.- // Ads owed: its file now loads, which a slow phone takes more than AD_STUCK_MS over.- val owed = LicenceRefusals.letAdPlay(app.myspoti.spotify.bridge.AdBlock.adsOwed, mirroring, refused = false)- val refused = ad != null && (ad.isBuffering || ad.speed == 0.0) && now - adSince > (if (owed) AD_OWED_STUCK_MS else AD_STUCK_MS)+ val refused = ad != null && (ad.isBuffering || ad.speed == 0.0) && now - adSince > AD_STUCK_MS// A video ad reports neither a position nor a speed the way an audio one does: it// is taken as playing from the start, so it is got past instead of waited on.val videoAd = ad?.item?.mediaType == "video"val playing = ad != null && !refused && (videoAd || now - adSince > AD_PLAYING_SKIP_MS) && !adReloaded- // Ads owed (Spotify refuses the licences): one that plays is let play, muted, to its- // end; one that does not, or a break past AD_BREAK_MAX_MS, is got past as before.- val owedPlays = owed && !refused- val stuck = refused || (playing && !owedPlays) || now - adSince > AD_BREAK_MAX_MS- if (playing && owedPlays && !adOwedLogged) {- adOwedLogged = true- bridge.logger?.invoke("ad plays on ${ad?.item?.name}: let play muted, Spotify refuses this account's licences")- }+ val stuck = refused || playing || now - adSince > AD_BREAK_MAX_MS// Measured on 20/10 (desktop, free account, a real ad with its audio refused): the// page now keeps a refused ad current for good (20 min, buffering at 0:00), and// neither the in-stream manager's skipToNext nor playing the next song moves it@@ -2391,8 +2354,6 @@ class SpotifyPlayer(private val bridge: Bridge, private val scope: CoroutineScopconst val AD_RESTORE_WAIT_MS = 6_000L/** A refused ad left current that long: the page will not move on by itself. */const val AD_STUCK_MS = 3_000L- /** [AD_STUCK_MS] while ads are owed (see AdBlock.adsOwed): the ad's file loads then. */- const val AD_OWED_STUCK_MS = 10_000L/*** An ad mute that old is lifted. The page never reports the end of a break, so a lost* unmute used to leave the phone silent until the app was restarted; longer than any addiff --git a/base/api-spotify/src/main/kotlin/app/myspoti/spotify/bridge/Bridge.kt b/base/api-spotify/src/main/kotlin/app/myspoti/spotify/bridge/Bridge.ktindex f6f33ccf..84473ad8 100644--- a/base/api-spotify/src/main/kotlin/app/myspoti/spotify/bridge/Bridge.kt+++ b/base/api-spotify/src/main/kotlin/app/myspoti/spotify/bridge/Bridge.kt@@ -140,8 +140,7 @@ class Bridge(private val host: BridgeHost, scope: CoroutineScope) {// re-announces only when the host is not ready (a page it thought it had lost).// The page's generation goes in with it: a call made for a page that went away is refused// by the next one (see [call]) instead of running there.- // Ads owed (AdBlock.adsOwed): the new page leaves its own ad managers on from the start.- host.evaluate("window.__mspPage = $pagesGone; window.__mspReannounce = ${!_ready.value}; window.__mspAdsOwed = ${AdBlock.adsOwed}; ${BridgeScript.source}")+ host.evaluate("window.__mspPage = $pagesGone; window.__mspReannounce = ${!_ready.value}; ${BridgeScript.source}")}/**diff --git a/base/api-spotify/src/main/kotlin/app/myspoti/spotify/bridge/BridgeHost.kt b/base/api-spotify/src/main/kotlin/app/myspoti/spotify/bridge/BridgeHost.ktindex cd4a027f..82bcf662 100644--- a/base/api-spotify/src/main/kotlin/app/myspoti/spotify/bridge/BridgeHost.kt+++ b/base/api-spotify/src/main/kotlin/app/myspoti/spotify/bridge/BridgeHost.kt@@ -70,27 +70,10 @@ object AdBlock {"fastly-insights.com",)- /** The trackers of [blockedHosts]: refused even while [adsOwed] (no ad needs them). */- private val trackerHosts = setOf("googletagmanager.com", "google-analytics.com", "scorecardresearch.com", "fastly-insights.com")-- /**- * Spotify refuses this account its audio licences (set by [app.myspoti.spotify.SpotifyPlayer]- * from three 403 in a row, cleared by the first audio licence granted again). Every report of- * it (#134 and five diagnostics, 26/10 to 03/11: free accounts, phones from three makers, L1- * and L3) has the same course: no audio licence granted at all, then an ad Spotify queues,- * whose file this app refuses, so the ad never plays and is never heard of again. Whether- * Spotify withholds the licences until an ad plays is not known; meanwhile nothing plays- * anyway, so the ads it queues are let through and play muted: their files load, the queue- * keeps them ([withoutAds], [adAhead] stand aside) and the page's ad managers stay on.- */- @Volatile var adsOwed = false-fun isBlocked(url: String): Boolean {val rest = url.substringAfter("://")val host = rest.substringBefore('/').substringBefore('?').substringBefore(':').lowercase()- fun matches(h: String) = host == h || host.endsWith(".$h")- if (adsOwed) return trackerHosts.any(::matches)- return blockedHosts.any(::matches)+ return blockedHosts.any { host == it || host.endsWith(".$it") }}/**@@ -105,7 +88,7 @@ object AdBlock {* is left as it is; an ad that is already the current state cannot be left out either.*/fun withoutAds(body: String): Pair<String, List<String>>? {- if (adsOwed || !AD_HINT.containsMatchIn(body)) return null+ if (!AD_HINT.containsMatchIn(body)) return nullval root = runCatching { Json.parseToJsonElement(body).jsonObject }.getOrNull() ?: return nullval notes = mutableListOf<String>()val out = root.toMutableMap()@@ -132,7 +115,7 @@ object AdBlock {/** The [AdAhead] in a track-playback reply (after [withoutAds]), or null. */fun adAhead(body: String): AdAhead? = runCatching {- if (adsOwed || !AD_HINT.containsMatchIn(body)) return null+ if (!AD_HINT.containsMatchIn(body)) return nullval root = Json.parseToJsonElement(body).jsonObjectval machine = root["state_machine"] as? JsonObject ?: return nullval tracks = machine["tracks"] as? JsonArray ?: return null@@ -181,7 +164,6 @@ object AdBlock {*/fun whyKept(body: String): String? = runCatching {val marker = AD_HINT.find(body)?.value?.trim('"') ?: return null- if (adsOwed) return "$marker: let through, Spotify refuses this account's licences"val root = Json.parseToJsonElement(body).jsonObjectval machine = root["state_machine"] as? JsonObject ?: return "$marker: no state machine in the reply"val tracks = machine["tracks"] as? JsonArray ?: return "$marker: no tracks"diff --git a/base/api-spotify/src/main/resources/bridge/player-bridge.js b/base/api-spotify/src/main/resources/bridge/player-bridge.jsindex a387590f..e3c256ce 100644--- a/base/api-spotify/src/main/resources/bridge/player-bridge.js+++ b/base/api-spotify/src/main/resources/bridge/player-bridge.js@@ -353,13 +353,8 @@// are left out of the queue by the host (AdBlock.withoutAds). The "Test ad" once taken for an// ad that came through was tools/playback_test.py's own fake.let adsLatched = false;- // Spotify refuses the account its audio licences (the host's AdBlock.adsOwed, set before the- // bridge is injected and by "ads.owed"): the ads it queues are let play, muted by the host, so- // the page's own managers are left on and drive them as on any free account.- const adsOwed = () => window.__mspAdsOwed === true;const adsOff = () => {if (!services) return 'not ready';- if (adsOwed()) return 'owed: left on';if (adsLatched) return 'already off';let audio = null;try { audio = services.resolve('AdManagers').audio; } catch (e) { return 'unresolved'; }@@ -379,30 +374,6 @@return done.length ? (adsLatched = true, done.join(',')) : 'nothing to disable';};- /**- * Ads owed or not. On: the latch of [adsOff] is undone (the instance's `enable` stand-in removed,- * the prototype's own run), so a break the server queues is played by the page's managers. Off:- * the managers are turned off again.- */- const adsOwedSet = on => {- window.__mspAdsOwed = !!on;- if (!on) return adsOff();- if (!services) return 'not ready';- let audio = null;- try { audio = services.resolve('AdManagers').audio; } catch (e) { return 'unresolved'; }- if (!audio) return 'no ad manager';- const done = [];- for (const [label, mgr] of [['audio', audio], ['inStream', audio.inStreamApi]]) {- if (!mgr) continue;- try {- if (Object.prototype.hasOwnProperty.call(mgr, 'enable')) delete mgr.enable;- if (typeof mgr.enable === 'function') { mgr.enable(); done.push(label); }- } catch (e) { /* left as it is */ }- }- adsLatched = false;- return done.length ? 'on: ' + done.join(',') : 'nothing to enable';- };-/*** Asks the in-stream ad manager to end its break. Kept for diagnosis only: on a real ad whose* audio was refused it did nothing (20/10), the server holds the ad ("ad_disallow").@@ -419,7 +390,6 @@const commands = {'bridge.version': () => VERSION,'ads.off': () => adsOff(),- 'ads.owed': args => adsOwedSet(!!(args && args.on)),'ads.skip': () => adsSkip(),'player.state': () => mapState(need().player.getState()),diff --git a/base/api-spotify/src/test/kotlin/app/myspoti/spotify/AdFlagTest.kt b/base/api-spotify/src/test/kotlin/app/myspoti/spotify/AdFlagTest.ktindex ca78233a..10942b27 100644--- a/base/api-spotify/src/test/kotlin/app/myspoti/spotify/AdFlagTest.kt+++ b/base/api-spotify/src/test/kotlin/app/myspoti/spotify/AdFlagTest.kt@@ -49,7 +49,6 @@ class AdFlagTest {@AfterEach fun down() {AdBlock.ahead.value = null- AdBlock.adsOwed = falsescope.cancel()}@@ -93,25 +92,4 @@ class AdFlagTest {waitFor("ad flag cleared", ms = 15_000) { !player.adPlaying.value }assertEquals("spotify:track:B", player.state.value?.item?.uri)}-- private fun licence(status: Int) =- """{"type":"net","url":"https://gew4-spclient.spotify.com/widevine-license/v1/audio/license","status":$status,"bytes":0,"ms":100}"""-- @Test fun `licences refused, ads owed until one is granted again (#134)`() = runBlocking {- host.post("""{"type":"ready"}""")- waitFor("page ready") { bridge.ready.value }- host.post("""{"type":"state","state":${stateOf(track("A"))}}""")- // The certificate is not a song's licence; one 403 is a song, not the account.- host.post("""{"type":"net","url":"https://gew4-spclient.spotify.com/widevine-license/v1/application-certificate","status":200,"bytes":0,"ms":100}""")- host.post(licence(403))- delay(300)- assertEquals(false, AdBlock.adsOwed)- host.post(licence(403)); host.post(licence(403))- waitFor("ads owed") { AdBlock.adsOwed && player.licencesHeld }- // The ad Spotify queues meanwhile loads its file.- assertEquals(false, AdBlock.isBlocked("https://adstudio-assets.scdn.co/mp3/x.mp3"))- host.post(licence(200))- waitFor("licences back") { !AdBlock.adsOwed && !player.licencesHeld }- assertEquals(true, AdBlock.isBlocked("https://adstudio-assets.scdn.co/mp3/x.mp3"))- }}diff --git a/base/api-spotify/src/test/kotlin/app/myspoti/spotify/LicenceRefusalsTest.kt b/base/api-spotify/src/test/kotlin/app/myspoti/spotify/LicenceRefusalsTest.ktindex 7f5b143b..862e6c0c 100644--- a/base/api-spotify/src/test/kotlin/app/myspoti/spotify/LicenceRefusalsTest.kt+++ b/base/api-spotify/src/test/kotlin/app/myspoti/spotify/LicenceRefusalsTest.kt@@ -28,13 +28,4 @@ class LicenceRefusalsTest {assertTrue(LicenceRefusals.isAudio("https://gew4-spclient.spotify.com/widevine-license/v1/audio/license"))assertFalse(LicenceRefusals.isAudio("https://gew4-spclient.spotify.com/widevine-license/v1/application/certificate"))}-- @Test fun `an ad that plays is let play only while ads are owed`() {- assertTrue(LicenceRefusals.letAdPlay(owed = true, mirroring = false, refused = false))- assertFalse(LicenceRefusals.letAdPlay(owed = false, mirroring = false, refused = false))- // A page that only mirrors an extension's song is reloaded as before.- assertFalse(LicenceRefusals.letAdPlay(owed = true, mirroring = true, refused = false))- // An ad whose file did not load never ends by itself.- assertFalse(LicenceRefusals.letAdPlay(owed = true, mirroring = false, refused = true))- }}diff --git a/base/api-spotify/src/test/kotlin/app/myspoti/spotify/bridge/AdBlockTest.kt b/base/api-spotify/src/test/kotlin/app/myspoti/spotify/bridge/AdBlockTest.ktindex cc1788cf..94284107 100644--- a/base/api-spotify/src/test/kotlin/app/myspoti/spotify/bridge/AdBlockTest.kt+++ b/base/api-spotify/src/test/kotlin/app/myspoti/spotify/bridge/AdBlockTest.kt@@ -13,19 +13,6 @@ class AdBlockTest {assertFalse(AdBlock.isBlocked("https://evil.com/adstudio-assets.scdn.co/x.mp3"))}- @Test- fun `ads owed, their files load and the trackers stay refused`() {- AdBlock.adsOwed = true- try {- assertFalse(AdBlock.isBlocked("https://adstudio-assets.scdn.co/mp3/d0448345e619692e0b13626ad4994d4b824f7107.mp3"))- assertFalse(AdBlock.isBlocked("https://pubads.g.doubleclick.net/gampad/ads?x=1"))- assertFalse(AdBlock.isBlocked("https://s0.2mdn.net/ads/richmedia/studio/abc.mp4"))- assertTrue(AdBlock.isBlocked("https://www.googletagmanager.com/gtm.js"))- assertTrue(AdBlock.isBlocked("https://sb.scorecardresearch.com/b"))- } finally { AdBlock.adsOwed = false }- assertTrue(AdBlock.isBlocked("https://adstudio-assets.scdn.co/mp3/d0448345e619692e0b13626ad4994d4b824f7107.mp3"))- }-@Testfun `blocks foreign ad servers only`() {assertTrue(AdBlock.isBlocked("https://pubads.g.doubleclick.net/gampad/ads?x=1"))diff --git a/base/api-spotify/src/test/kotlin/app/myspoti/spotify/bridge/AdQueueTest.kt b/base/api-spotify/src/test/kotlin/app/myspoti/spotify/bridge/AdQueueTest.ktindex 32abc77c..93357376 100644--- a/base/api-spotify/src/test/kotlin/app/myspoti/spotify/bridge/AdQueueTest.kt+++ b/base/api-spotify/src/test/kotlin/app/myspoti/spotify/bridge/AdQueueTest.kt@@ -52,17 +52,6 @@ class AdQueueTest {assertEquals(listOf("advance after Playing: After instead of an ad"), notes)}- @Test fun `ads owed are left in the queue`() {- AdBlock.adsOwed = true- try {- assertNull(AdBlock.withoutAds(first))- assertNull(AdBlock.adAhead(second))- assertTrue(AdBlock.whyKept(first)!!.contains("let through"))- } finally { AdBlock.adsOwed = false }- // Once a licence is granted again, they are left out as before.- assertTrue(AdBlock.withoutAds(first) != null)- }-@Test fun `when the skip goes to the ad too, the reply is left as it is`() =// show_next is a display-only state: the server refuses a page sent there (502).assertNull(AdBlock.withoutAds(second))diff --git a/base/app/src/main/java/com/music/spotui/di/SongPlayer.kt b/base/app/src/main/java/com/music/spotui/di/SongPlayer.ktindex faf3f9fa..93122f3d 100644--- a/base/app/src/main/java/com/music/spotui/di/SongPlayer.kt+++ b/base/app/src/main/java/com/music/spotui/di/SongPlayer.kt@@ -344,7 +344,13 @@ object SongPlayer {}scope.launch {MyspotiRuntime.spotify.player.licencesRefused.collect {- android.widget.Toast.makeText(Graph.app, app.myspoti.engine.R.string.licences_refused_by_spotify, android.widget.Toast.LENGTH_LONG).show()+ // A Widevine older than Spotify still accepts is the phone, not the account: waiting+ // or another account changes nothing, an extension's source does.+ val drm = app.myspoti.host.android.Widevine.version+ val text = if (app.myspoti.host.android.Widevine.tooOld(drm))+ Graph.app.getString(app.myspoti.engine.R.string.licences_refused_old_widevine, drm?.substringBefore('@'))+ else Graph.app.getString(app.myspoti.engine.R.string.licences_refused_by_spotify)+ android.widget.Toast.makeText(Graph.app, text, android.widget.Toast.LENGTH_LONG).show()}}// Said once the page has asked its WebView: a device that cannot decrypt Spotify's streamsdiff --git a/base/app/src/main/res/values-de/myspoti_strings.xml b/base/app/src/main/res/values-de/myspoti_strings.xmlindex e7488743..106a8aeb 100644--- a/base/app/src/main/res/values-de/myspoti_strings.xml+++ b/base/app/src/main/res/values-de/myspoti_strings.xml@@ -516,6 +516,7 @@<string name="song_unavailable">%1$s ist nicht verfügbar.</string><string name="songs_skipped_by_spotify">Spotify hat immer wieder Titel übersprungen, die es nicht abspielen konnte, daher wurde die Wiedergabe pausiert. Tippe auf Wiedergabe, um es erneut zu versuchen, oder prüfe dein Konto und deine Verbindung.</string><string name="licences_refused_by_spotify">Spotify verweigert auf diesem Konto gerade die Wiedergabe (Audiolizenz abgelehnt), daher wurde die Wiedergabe pausiert. Warte etwas und tippe auf Wiedergabe, um es erneut zu versuchen, und prüfe, ob das Konto in der offiziellen Spotify-App abspielt.</string>+ <string name="licences_refused_old_widevine">Spotify verweigert die Audiolizenzen dieses Telefons: Sein DRM (Widevine %1$s) ist älter als das, was der Spotify-Webplayer akzeptiert, unabhängig vom Konto, daher wurde die Wiedergabe pausiert. Spotify-Titel können auf diesem Telefon nicht über Myspoti abgespielt werden; eine Audioquellen-Erweiterung kann sie abspielen.</string><string name="playlist_leave">Playlist verlassen</string><string name="playlist_leave_confirm">%1$s verlassen? Du bist dann kein Mitwirkender mehr und kannst keine Titel mehr hinzufügen oder entfernen. Um wieder beizutreten, brauchst du einen neuen Einladungslink.</string><string name="playlist_leave_button">Verlassen</string>diff --git a/base/app/src/main/res/values-el/myspoti_strings.xml b/base/app/src/main/res/values-el/myspoti_strings.xmlindex 9514afc4..631e3bac 100644--- a/base/app/src/main/res/values-el/myspoti_strings.xml+++ b/base/app/src/main/res/values-el/myspoti_strings.xml@@ -516,6 +516,7 @@<string name="song_unavailable">Το «%1$s» δεν είναι διαθέσιμο.</string><string name="songs_skipped_by_spotify">Το Spotify συνέχιζε να παραλείπει τραγούδια που δεν μπορούσε να αναπαραγάγει, οπότε η αναπαραγωγή τέθηκε σε παύση. Πατήστε αναπαραγωγή για νέα προσπάθεια ή ελέγξτε τον λογαριασμό και τη σύνδεσή σας.</string><string name="licences_refused_by_spotify">Το Spotify αρνείται προς το παρόν την αναπαραγωγή τραγουδιών σε αυτόν τον λογαριασμό (η άδεια ήχου απορρίφθηκε), οπότε η αναπαραγωγή τέθηκε σε παύση. Περιμένετε λίγο και πατήστε αναπαραγωγή για νέα προσπάθεια, και ελέγξτε ότι ο λογαριασμός παίζει στην επίσημη εφαρμογή Spotify.</string>+ <string name="licences_refused_old_widevine">Το Spotify αρνείται τις άδειες ήχου αυτού του τηλεφώνου: το DRM του (Widevine %1$s) είναι παλαιότερο από ό,τι δέχεται το web player του Spotify, όποιος κι αν είναι ο λογαριασμός, γι’ αυτό η αναπαραγωγή σταμάτησε. Τα τραγούδια του Spotify δεν μπορούν να παιχτούν από το Myspoti σε αυτό το τηλέφωνο· μια επέκταση πηγής ήχου μπορεί να τα παίξει.</string><string name="playlist_leave">Αποχώρηση από τη λίστα αναπαραγωγής</string><string name="playlist_leave_confirm">Αποχώρηση από το «%1$s»; Δεν θα είστε πλέον συνεργάτης και δεν θα μπορείτε να προσθέτετε ή να αφαιρείτε τραγούδια. Για να ξαναμπείτε, θα χρειαστείτε νέο σύνδεσμο πρόσκλησης.</string><string name="playlist_leave_button">Αποχώρηση</string>diff --git a/base/app/src/main/res/values-es/myspoti_strings.xml b/base/app/src/main/res/values-es/myspoti_strings.xmlindex 478c2440..0c5b1992 100644--- a/base/app/src/main/res/values-es/myspoti_strings.xml+++ b/base/app/src/main/res/values-es/myspoti_strings.xml@@ -516,6 +516,7 @@<string name="song_unavailable">%1$s no está disponible.</string><string name="songs_skipped_by_spotify">Spotify seguía omitiendo canciones que no podía reproducir, así que la reproducción se pausó. Toca reproducir para intentarlo de nuevo, o revisa tu cuenta y tu conexión.</string><string name="licences_refused_by_spotify">Spotify se niega ahora mismo a reproducir canciones en esta cuenta (licencia de audio rechazada), así que la reproducción se pausó. Espera un poco y toca reproducir para intentarlo de nuevo, y comprueba que la cuenta funciona en la aplicación oficial de Spotify.</string>+ <string name="licences_refused_old_widevine">Spotify rechaza las licencias de audio de este teléfono: su DRM (Widevine %1$s) es más antiguo de lo que acepta el reproductor web de Spotify, sea cual sea la cuenta, así que la reproducción se pausó. Las canciones de Spotify no pueden reproducirse desde Myspoti en este teléfono; una extensión de fuente de audio puede reproducirlas.</string><string name="playlist_leave">Salir de la playlist</string><string name="playlist_leave_confirm">¿Salir de %1$s? Dejarás de ser colaborador y no podrás añadir ni quitar canciones. Para volver a unirte, necesitarás un nuevo enlace de invitación.</string><string name="playlist_leave_button">Salir</string>diff --git a/base/app/src/main/res/values-fr/myspoti_strings.xml b/base/app/src/main/res/values-fr/myspoti_strings.xmlindex 6311db8e..653e1445 100644--- a/base/app/src/main/res/values-fr/myspoti_strings.xml+++ b/base/app/src/main/res/values-fr/myspoti_strings.xml@@ -446,6 +446,7 @@<string name="song_unavailable">%1$s est indisponible.</string><string name="songs_skipped_by_spotify">Spotify enchaînait des morceaux qu’il ne pouvait pas lire : la lecture a été mise en pause. Appuyez sur lecture pour réessayer, ou vérifiez votre compte et votre connexion.</string><string name="licences_refused_by_spotify">Spotify refuse pour l’instant de lire des morceaux sur ce compte (licence audio refusée) : la lecture a été mise en pause. Patientez un moment puis appuyez sur lecture pour réessayer, et vérifiez que le compte fonctionne dans l’application Spotify officielle.</string>+ <string name="licences_refused_old_widevine">Spotify refuse les licences audio de ce téléphone : sa DRM (Widevine %1$s) est plus ancienne que ce qu’accepte le lecteur web de Spotify, quel que soit le compte, donc la lecture a été mise en pause. Les morceaux Spotify ne peuvent pas être lus depuis Myspoti sur ce téléphone ; une extension de source audio peut les lire.</string><string name="spotify_limited">Spotify limite la lecture pour le moment. Réessayez dans une minute.</string><string name="library_change_undone">Spotify a refusé la modification, votre bibliothèque est revenue comme avant</string><string name="blend_title">Mix à plusieurs</string>diff --git a/base/app/src/main/res/values-it/myspoti_strings.xml b/base/app/src/main/res/values-it/myspoti_strings.xmlindex ca0437de..04398f05 100644--- a/base/app/src/main/res/values-it/myspoti_strings.xml+++ b/base/app/src/main/res/values-it/myspoti_strings.xml@@ -516,6 +516,7 @@<string name="song_unavailable">%1$s non è disponibile.</string><string name="songs_skipped_by_spotify">Spotify continuava a saltare brani che non riusciva a riprodurre, quindi la riproduzione è stata messa in pausa. Tocca riproduci per riprovare oppure controlla il tuo account e la connessione.</string><string name="licences_refused_by_spotify">Spotify per ora rifiuta di riprodurre brani su questo account (licenza audio rifiutata), quindi la riproduzione è stata messa in pausa. Aspetta un po’ e tocca riproduci per riprovare, e controlla che l’account funzioni nell’app ufficiale di Spotify.</string>+ <string name="licences_refused_old_widevine">Spotify rifiuta le licenze audio di questo telefono: il suo DRM (Widevine %1$s) è più vecchio di quanto accetta il web player di Spotify, qualunque sia l’account, quindi la riproduzione è stata messa in pausa. I brani Spotify non possono essere riprodotti da Myspoti su questo telefono; un’estensione di sorgente audio può riprodurli.</string><string name="playlist_leave">Esci dalla playlist</string><string name="playlist_leave_confirm">Uscire da %1$s? Non sarai più un collaboratore e non potrai aggiungere o rimuovere brani. Per rientrare ti servirà un nuovo link di invito.</string><string name="playlist_leave_button">Esci</string>diff --git a/base/app/src/main/res/values-pl/myspoti_strings.xml b/base/app/src/main/res/values-pl/myspoti_strings.xmlindex fb7c87f5..400430ac 100644--- a/base/app/src/main/res/values-pl/myspoti_strings.xml+++ b/base/app/src/main/res/values-pl/myspoti_strings.xml@@ -541,6 +541,7 @@<string name="song_unavailable">Utwór %1$s jest niedostępny.</string><string name="songs_skipped_by_spotify">Spotify wciąż pomijał utwory, których nie mógł odtworzyć, więc odtwarzanie wstrzymano. Dotknij odtwarzania, aby spróbować ponownie, lub sprawdź konto i połączenie.</string><string name="licences_refused_by_spotify">Spotify na razie odmawia odtwarzania utworów na tym koncie (licencja audio odrzucona), więc odtwarzanie wstrzymano. Poczekaj chwilę i dotknij odtwarzania, aby spróbować ponownie, oraz sprawdź, czy konto działa w oficjalnej aplikacji Spotify.</string>+ <string name="licences_refused_old_widevine">Spotify odrzuca licencje audio tego telefonu: jego DRM (Widevine %1$s) jest starszy niż to, co akceptuje odtwarzacz internetowy Spotify, niezależnie od konta, więc odtwarzanie zostało wstrzymane. Utworów Spotify nie da się odtwarzać z Myspoti na tym telefonie; rozszerzenie źródła dźwięku może je odtwarzać.</string><string name="playlist_member_listener">Słuchacz</string><string name="playlist_member_remove_collab">Usuń z grona współtwórców</string><string name="playlist_member_make_collab">Zrób współtwórcą</string>diff --git a/base/app/src/main/res/values-pt-rBR/myspoti_strings.xml b/base/app/src/main/res/values-pt-rBR/myspoti_strings.xmlindex 3da33030..c89ebb51 100644--- a/base/app/src/main/res/values-pt-rBR/myspoti_strings.xml+++ b/base/app/src/main/res/values-pt-rBR/myspoti_strings.xml@@ -445,6 +445,7 @@<string name="song_unavailable">%1$s está indisponível.</string><string name="songs_skipped_by_spotify">O Spotify continuou pulando músicas que não conseguiu tocar, então a reprodução foi pausada. Toque em reproduzir para tentar de novo, ou verifique sua conta e sua conexão.</string><string name="licences_refused_by_spotify">O Spotify está se recusando a tocar músicas nesta conta por ora (licença de áudio recusada), então a reprodução foi pausada. Aguarde um pouco e toque em reproduzir para tentar de novo, e confira se a conta funciona no app oficial do Spotify.</string>+ <string name="licences_refused_old_widevine">O Spotify recusa as licenças de áudio deste celular: o DRM dele (Widevine %1$s) é mais antigo do que o player web do Spotify aceita, seja qual for a conta, então a reprodução foi pausada. As músicas do Spotify não podem tocar pelo Myspoti neste celular; uma extensão de fonte de áudio pode tocá-las.</string><string name="spotify_limited">O Spotify está limitando a reprodução por um momento. Tente novamente em um minuto.</string><string name="library_change_undone">O Spotify recusou a alteração, sua biblioteca voltou ao que era</string><string name="blend_title">Blend</string>diff --git a/base/app/src/main/res/values-pt/myspoti_strings.xml b/base/app/src/main/res/values-pt/myspoti_strings.xmlindex 2d74bac5..348a7006 100644--- a/base/app/src/main/res/values-pt/myspoti_strings.xml+++ b/base/app/src/main/res/values-pt/myspoti_strings.xml@@ -516,6 +516,7 @@<string name="song_unavailable">%1$s não está disponível.</string><string name="songs_skipped_by_spotify">O Spotify continuou pulando músicas que não conseguia reproduzir, então a reprodução foi pausada. Toque em reproduzir para tentar de novo ou verifique sua conta e sua conexão.</string><string name="licences_refused_by_spotify">O Spotify está recusando reproduzir músicas nesta conta por enquanto (licença de áudio recusada), então a reprodução foi pausada. Aguarde um pouco e toque em reproduzir para tentar de novo, e verifique se a conta funciona no app oficial do Spotify.</string>+ <string name="licences_refused_old_widevine">O Spotify recusa as licenças de áudio deste telemóvel: o DRM dele (Widevine %1$s) é mais antigo do que o leitor web do Spotify aceita, seja qual for a conta, por isso a reprodução foi pausada. As músicas do Spotify não podem ser reproduzidas pelo Myspoti neste telemóvel; uma extensão de fonte de áudio pode reproduzi-las.</string><string name="playlist_leave">Sair da playlist</string><string name="playlist_leave_confirm">Sair de %1$s? Você deixará de ser colaborador e não poderá adicionar nem remover músicas. Para entrar de novo, você precisará de um novo link de convite.</string><string name="playlist_leave_button">Sair</string>diff --git a/base/app/src/main/res/values-ru/myspoti_strings.xml b/base/app/src/main/res/values-ru/myspoti_strings.xmlindex e93a53b0..dab6b3ed 100644--- a/base/app/src/main/res/values-ru/myspoti_strings.xml+++ b/base/app/src/main/res/values-ru/myspoti_strings.xml@@ -541,6 +541,7 @@<string name="song_unavailable">Трек «%1$s» недоступен.</string><string name="songs_skipped_by_spotify">Spotify продолжал пропускать треки, которые не смог воспроизвести, поэтому воспроизведение приостановлено. Нажмите «Воспроизвести», чтобы повторить, или проверьте аккаунт и подключение.</string><string name="licences_refused_by_spotify">Spotify пока отказывается воспроизводить треки на этом аккаунте (аудиолицензия отклонена), поэтому воспроизведение приостановлено. Немного подождите и нажмите «Воспроизвести», чтобы повторить, и проверьте, работает ли аккаунт в официальном приложении Spotify.</string>+ <string name="licences_refused_old_widevine">Spotify отклоняет аудиолицензии этого телефона: его DRM (Widevine %1$s) старее, чем принимает веб-плеер Spotify, независимо от аккаунта, поэтому воспроизведение приостановлено. Треки Spotify нельзя воспроизвести через Myspoti на этом телефоне; расширение-источник аудио может их воспроизвести.</string><string name="playlist_member_listener">Слушатель</string><string name="playlist_member_remove_collab">Убрать из соавторов</string><string name="playlist_member_make_collab">Сделать соавтором</string>diff --git a/base/app/src/main/res/values-zh/myspoti_strings.xml b/base/app/src/main/res/values-zh/myspoti_strings.xmlindex 5f2b077c..57eb6cab 100644--- a/base/app/src/main/res/values-zh/myspoti_strings.xml+++ b/base/app/src/main/res/values-zh/myspoti_strings.xml@@ -532,6 +532,7 @@<string name="song_unavailable">%1$s 不可用。</string><string name="songs_skipped_by_spotify">Spotify 不断跳过无法播放的歌曲,因此播放已暂停。点按播放重试,或检查你的账号和网络连接。</string><string name="licences_refused_by_spotify">Spotify 暂时拒绝在此账号上播放歌曲(音频许可被拒绝),因此播放已暂停。请稍等片刻后点按播放重试,并检查该账号能否在官方 Spotify 应用中正常播放。</string>+ <string name="licences_refused_old_widevine">Spotify 拒绝了此手机的音频许可:它的 DRM(Widevine %1$s)比 Spotify 网页播放器接受的版本更旧,与账号无关,因此已暂停播放。在此手机上无法通过 Myspoti 播放 Spotify 歌曲;音频来源扩展可以播放它们。</string><string name="playlist_member_listener">听众</string><string name="playlist_member_remove_collab">取消协作者身份</string><string name="playlist_member_make_collab">设为协作者</string>diff --git a/base/app/src/main/res/values/myspoti_strings.xml b/base/app/src/main/res/values/myspoti_strings.xmlindex af314310..7cd2c9e0 100644--- a/base/app/src/main/res/values/myspoti_strings.xml+++ b/base/app/src/main/res/values/myspoti_strings.xml@@ -456,6 +456,7 @@<string name="song_unavailable">%1$s is unavailable.</string><string name="songs_skipped_by_spotify">Spotify kept skipping songs it could not play, so playback was paused. Tap play to try again, or check your account and connection.</string><string name="licences_refused_by_spotify">Spotify is refusing to play songs on this account right now (audio licence refused), so playback was paused. Wait a while and tap play to try again, and check that the account plays in the official Spotify app.</string>+ <string name="licences_refused_old_widevine">Spotify refuses this phone’s audio licences: its DRM (Widevine %1$s) is older than what Spotify’s web player accepts, whatever the account, so playback was paused. Spotify songs cannot play from Myspoti on this phone; an audio-source extension can play them.</string><string name="spotify_limited">Spotify is limiting playback for a moment. Try again in a minute.</string><string name="library_change_undone">Spotify refused the change, your library is back as it was</string><string name="blend_title">Blend</string>diff --git a/base/host-android/src/main/kotlin/app/myspoti/host/android/Widevine.kt b/base/host-android/src/main/kotlin/app/myspoti/host/android/Widevine.ktnew file mode 100644index 00000000..45dbc6a3--- /dev/null+++ b/base/host-android/src/main/kotlin/app/myspoti/host/android/Widevine.kt@@ -0,0 +1,25 @@+package app.myspoti.host.android++/**+ * The phone's Widevine, as MediaDrm reports it. Every diagnostic with Spotify refusing each song's+ * audio licence (403, from the very first song, before any ad) came from a phone on Widevine 15.0+ * or 16.0 (Lenovo TB-X606F, Pixel 3, Xiaomi Mi 9T, OnePlus 5T; L1 and L3 alike, all free accounts,+ * like the ones that play); none of the phones on 18.0 had it.+ */+object Widevine {+ /** "15.0.0", "18.0.0@343213000", or null when MediaDrm does not answer. Read once. */+ val version: String? by lazy {+ runCatching {+ val drm = android.media.MediaDrm(java.util.UUID.fromString("edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"))+ try { drm.getPropertyString("version") }+ finally { if (android.os.Build.VERSION.SDK_INT >= 28) drm.close() else @Suppress("DEPRECATION") drm.release() }+ }.getOrNull()+ }++ /** True for a version below 16.1, the ones seen refused; false when it cannot be read. */+ fun tooOld(version: String?): Boolean {+ val m = Regex("""^(\d+)\.(\d+)""").find(version ?: return false) ?: return false+ val major = m.groupValues[1].toInt()+ return major < 16 || (major == 16 && m.groupValues[2].toInt() < 1)+ }+}diff --git a/base/host-android/src/test/kotlin/app/myspoti/host/android/WidevineTest.kt b/base/host-android/src/test/kotlin/app/myspoti/host/android/WidevineTest.ktnew file mode 100644index 00000000..b9872082--- /dev/null+++ b/base/host-android/src/test/kotlin/app/myspoti/host/android/WidevineTest.kt@@ -0,0 +1,19 @@+package app.myspoti.host.android++import org.junit.Assert.assertFalse+import org.junit.Assert.assertTrue+import org.junit.Test++class WidevineTest {+ @Test fun theVersionsSeenRefusedAreTooOld() {+ assertTrue(Widevine.tooOld("15.0.0"))+ assertTrue(Widevine.tooOld("16.0.0"))+ }++ @Test fun newerOrUnreadableVersionsAreNot() {+ assertFalse(Widevine.tooOld("16.1.1@014"))+ assertFalse(Widevine.tooOld("18.0.0@343213000"))+ assertFalse(Widevine.tooOld("***@***"))+ assertFalse(Widevine.tooOld(null))+ }+}