Unofficial YouTube Music / Spotify Premium client for Android, built in Liquid Glass. Audio effects, Spotify Connect, listening history, 8 languages. Rust core on librespot.
Kotlin alternativeandroidandroid-applicationclientglassmorphisminnertubelibrespotliquid-glassspotifyspotify-connectspotifyapiyoutube-musicyoutube-playerytdlnis
Tell a refused account so within a minute, and never play a file undecrypted
Lelonio15f53cb6a101
diff --git a/app/src/main/java/dev/lelonio/square/playback/LibrespotPlayer.kt b/app/src/main/java/dev/lelonio/square/playback/LibrespotPlayer.ktindex c156b7d..25aab28 100644--- a/app/src/main/java/dev/lelonio/square/playback/LibrespotPlayer.kt+++ b/app/src/main/java/dev/lelonio/square/playback/LibrespotPlayer.kt@@ -1556,13 +1556,10 @@ class LibrespotPlayer(} else if (refusalShown) {return}- // The whole account refused: there is another way to play it.- if (account) {- dev.lelonio.square.backend.spotify.SpotifyWebPlayback.reportAccountRefused()- refusalShown = true- return- }refusalShown = true+ // Said first, whatever happens next: an account refused every key was+ // otherwise left with the advice to wait a few minutes, which cannot+ // help, or with only the web player's setup and no reason for it.android.widget.Toast.makeText(appContext,appContext.getString(@@ -1574,6 +1571,10 @@ class LibrespotPlayer(),android.widget.Toast.LENGTH_LONG,).show()+ // The whole account refused: there is another way to play it.+ if (account) {+ dev.lelonio.square.backend.spotify.SpotifyWebPlayback.reportAccountRefused()+ }}/**diff --git a/native/vendor/README.md b/native/vendor/README.mdindex e29cecf..3082bd6 100644--- a/native/vendor/README.md+++ b/native/vendor/README.md@@ -111,13 +111,16 @@ when the session does.A refusal is also reported, through `on_playback_refusal`, so the app can saywhy a song is not starting instead of leaving it at the start with no time on-it. Only refusals that land within a minute of the player asking for a key are-reported, once for a run of them, and the next key that comes back is reported-as the end of it. Downloads refused while nothing is playing say nothing. When-no key at all has come back since the app started and the refusals have gone on-for two minutes, the refusal is reported as the account's instead: Spotify-refuses every key to some accounts (librespot#1649), and for those waiting a few-minutes is the wrong advice.+it. Only refusals that land within ninety seconds of the player asking for a+key are reported, once for a run of them, and the next key that comes back is+reported as the end of it. Downloads refused while nothing is playing say+nothing. When no key at all has come back since the app started and the+refusals have gone on for seventy seconds, the refusal is reported as the+account's instead: Spotify refuses every key to some accounts (librespot#1649),+and for those waiting a few minutes is the wrong advice. The window is longer+than the burst Spotify refuses for, about a minute, and short enough that the+refusals one press of play produces reach it; at two minutes they did not, and+an account refused every key was told to wait.And a reply of the wrong size is refused rather than trusted. Upstream copiesthe key with `copy_from_slice` and reads the error code by index, both of which@@ -225,8 +228,10 @@ second, the engine moves to the next one, and that one is refused too. Nothingin the log says the word key.A refusal or a timeout now ends the load, which puts it on the retry path with-the rest, and says so if it still cannot be played. Any other key failure keeps-upstream's behaviour, since a genuinely unencrypted file has to go on playing.+the rest, and says so if it still cannot be played. So does a key lost because+the session went away mid-request, which answers "channel closed". Any other key+failure keeps upstream's behaviour, since a genuinely unencrypted file has to go+on playing.See also the retry in `librespot-core`'s `audio_key.rs`, which is what tries arefused key again before it gets this far.diff --git a/native/vendor/librespot-core/src/audio_key.rs b/native/vendor/librespot-core/src/audio_key.rsindex bc7fc8c..f2de5b8 100644--- a/native/vendor/librespot-core/src/audio_key.rs+++ b/native/vendor/librespot-core/src/audio_key.rs@@ -140,10 +140,19 @@ enum Refusal {}/// How recent a playback request has to be for a refusal to be its.-const PLAYBACK_WAITING: Duration = Duration::from_secs(60);+///+/// Longer than one load's own retries take: three refusals with the hold+/// doubling between them, plus the player trying the load again, run past a+/// minute, and at sixty seconds the last refusals of a load stopped counting.+const PLAYBACK_WAITING: Duration = Duration::from_secs(90);/// How long refusals with no key in between make it the account's.-const ACCOUNT_AFTER: Duration = Duration::from_secs(120);+///+/// A burst of requests is refused for about a minute. At two minutes, the+/// refusals one press of play produces never got that far, so an account that+/// was refused every key was told for several minutes to wait and try again,+/// which could not help.+const ACCOUNT_AFTER: Duration = Duration::from_secs(70);/// Sets where refusals are reported; see [ON_PLAYBACK_REFUSAL]. Only the first/// call counts.diff --git a/native/vendor/librespot-playback/src/player.rs b/native/vendor/librespot-playback/src/player.rsindex 393b9aa..1e7e5f2 100644--- a/native/vendor/librespot-playback/src/player.rs+++ b/native/vendor/librespot-playback/src/player.rs@@ -1692,11 +1692,15 @@ impl PlayerTrackLoader {let key = match self.session.audio_key().request(track_id, file_id).await {Ok(key) => Some(key),Err(e) => {+ // A key that never came because the session went away+ // counts too: the connection dropping mid-request answers+ // "channel closed", and the file is no less encrypted for+ // it. Played anyway, it was a decoder error and a skip.let refused = matches!(e.error.downcast_ref::<librespot_core::audio_key::AudioKeyError>(),Some(librespot_core::audio_key::AudioKeyError::AesKey)| Some(librespot_core::audio_key::AudioKeyError::Timeout)- );+ ) || self.session.is_invalid();if refused {warn!("no key for <{track_id:?}>, not playing it undecrypted: {e}");return None;