Skip to content

Unofficial YouTube Music / Spotify Premium client for Android, built in Liquid Glass. Audio effects, Spotify Connect, listening history, 8 languages. Rust core on librespot.

Fall back to the Web API when rootlist is down

Lelonioe8fab91bb94e
diff --git a/.claude/settings.local.json b/.claude/settings.local.json
index 34f9685..fbd3725 100644
--- a/.claude/settings.local.json
+++ b/.claude/settings.local.json
@@ -135,7 +135,8 @@
"Bash(git commit -q -m 'Use the supplied icon artwork *)",
"Bash(python3 tools/icon.py)",
"Bash(git commit -q -m 'Regenerate icons from source, sized by the wave *)",
- "Bash(git commit -q -m 'New light icon artwork *)"
+ "Bash(git commit -q -m 'New light icon artwork *)",
+ "Bash(git commit -q -m 'Fall back to the Web API when rootlist is down *)"
]
}
}
diff --git a/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin b/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin
index 1624394..c7eacc3 100644
--- a/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin
+++ b/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin
@@ -2,27 +2,27 @@ C/C++ Structured Logl
j
h/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/additional_project_files.txtC
A
-?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  �����3  ����3i
+?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  �����3  ����3i
g
-e/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/android_gradle_build.json  �����3� ����3n
+e/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/android_gradle_build.json  �����3� ����3n
l
-j/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/android_gradle_build_mini.json  �����3� �����3[
+j/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/android_gradle_build_mini.json  �����3� �����3[
Y
-W/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build.ninja  �����3�� ����3_
+W/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build.ninja  �����3�� ����3_
]
-[/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build.ninja.txt  �����3d
+[/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build.ninja.txt  �����3d
b
-`/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build_file_index.txt  �����3 @ ����3e
+`/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build_file_index.txt  �����3 @ ����3e
c
-a/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/compile_commands.json  �����3�� ����3i
+a/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/compile_commands.json  �����3�� ����3i
g
-e/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/compile_commands.json.bin  �����3 �" ����3o
+e/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/compile_commands.json.bin  �����3 �" ����3o
m
-k/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/metadata_generation_command.txt  �����3
+k/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/metadata_generation_command.txt  �����3
� ����3b
`
-^/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/prefab_config.json  �����3  ( ����3g
+^/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/prefab_config.json  �����3  ( ����3g
e
-c/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/symbol_folder_index.txt  �����3  b ����3D
+c/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/symbol_folder_index.txt  �����3  b ����3D
B
-@/Users/emanuele/Progetto Spotify/app/src/main/cpp/CMakeLists.txt  �����3 � �Ȅ��3
\ No newline at end of file
+@/Users/emanuele/Progetto Spotify/app/src/main/cpp/CMakeLists.txt  �����3 � �Ȅ��3
\ No newline at end of file
diff --git a/app/src/main/java/dev/emanuele/spot/ui/MainViewModel.kt b/app/src/main/java/dev/emanuele/spot/ui/MainViewModel.kt
index 488da76..123b39d 100644
--- a/app/src/main/java/dev/emanuele/spot/ui/MainViewModel.kt
+++ b/app/src/main/java/dev/emanuele/spot/ui/MainViewModel.kt
@@ -555,7 +555,7 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {
}
_state.value = UiState.Loading
- runCatching { UiState.Ready(Catalog.username(), Catalog.playlists()) }
+ runCatching { UiState.Ready(Catalog.username(), playlists()) }
.onSuccess {
_state.value = it
loadProfile()
@@ -573,6 +573,31 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {
* already on screen with the account name by the time this runs, and an
* account with no Web API application connected simply keeps it.
*/
+ /**
+ * The account's playlists, from the access point or from the Web API.
+ *
+ * The access point is asked first: it is the same list, it needs no
+ * registered application, and it carries the playlists this account follows
+ * as well as its own. But `rootlist` answers 502 often enough to matter —
+ * a Spotify-side failure nothing here can prevent — and losing the whole
+ * library screen to it is out of proportion, since the Web API can answer
+ * the same question.
+ */
+ private suspend fun playlists(): List<CatalogPlaylist> =
+ runCatching { Catalog.playlists() }
+ .onFailure { android.util.Log.w(TAG, "rootlist unavailable: ${describe(it)}") }
+ .recoverCatching {
+ check(container.webApi.isReady) { it.message ?: "rootlist non disponibile" }
+ container.api.playlists(limit = WEB_API_PAGE).items.map { dto ->
+ CatalogPlaylist(
+ uri = dto.uri,
+ name = dto.name,
+ artworkUrl = dto.images.firstOrNull()?.url,
+ )
+ }
+ }
+ .getOrThrow()
+
private fun loadProfile() = viewModelScope.launch {
if (!container.webApi.isReady) return@launch
runCatching { container.api.me() }