mirror of
https://github.com/Shabinder/SpotiFlyer.git
synced 2024-11-22 09:04:32 +01:00
Saavn Internal Error Bug fix
This commit is contained in:
parent
4e539bbaae
commit
48e4c04973
@ -13,6 +13,7 @@ import io.github.shabinder.utils.getJsonArray
|
||||
import io.github.shabinder.utils.getJsonObject
|
||||
import io.github.shabinder.utils.getString
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.features.ServerResponseException
|
||||
import io.ktor.client.request.get
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonArray
|
||||
@ -52,17 +53,21 @@ interface JioSaavnRequests {
|
||||
|
||||
val searchURL = search_base_url + query
|
||||
val results = mutableListOf<SaavnSearchResult>()
|
||||
try {
|
||||
(globalJson.parseToJsonElement(httpClient.get(searchURL)) as JsonObject).getJsonObject("songs").getJsonArray("data")?.forEach {
|
||||
(it as? JsonObject)?.formatData()?.let { jsonObject ->
|
||||
results.add(globalJson.decodeFromJsonElement(SaavnSearchResult.serializer(), jsonObject))
|
||||
}
|
||||
}
|
||||
}catch (e: ServerResponseException) {}
|
||||
return results
|
||||
}
|
||||
|
||||
suspend fun getLyrics(ID: String): String? {
|
||||
return (Json.parseToJsonElement(httpClient.get(lyrics_base_url + ID)) as JsonObject)
|
||||
return try {
|
||||
(Json.parseToJsonElement(httpClient.get(lyrics_base_url + ID)) as JsonObject)
|
||||
.getString("lyrics")
|
||||
}catch (e:Exception) { null }
|
||||
}
|
||||
|
||||
suspend fun getSong(
|
||||
@ -74,6 +79,7 @@ interface JioSaavnRequests {
|
||||
.formatData(fetchLyrics)
|
||||
return globalJson.decodeFromJsonElement(SaavnSong.serializer(), data)
|
||||
}
|
||||
|
||||
suspend fun getSongFromID(
|
||||
ID: String,
|
||||
fetchLyrics: Boolean = false
|
||||
|
Loading…
Reference in New Issue
Block a user