Ktor Parsing Error Fix and Bump to v3.6.1

This commit is contained in:
Shabinder 2022-01-27 15:39:33 +05:30
parent 1b929b7449
commit c15b70b996
7 changed files with 36 additions and 36 deletions

View File

@ -32,7 +32,7 @@ jobs:
with: with:
draft: true draft: true
allowUpdates: true allowUpdates: true
tag: "v3.6.0" tag: "v3.6.1"
artifacts: "desktop/build/compose/jars/*.jar,desktop/build/compose/binaries/main/*/*" artifacts: "desktop/build/compose/jars/*.jar,desktop/build/compose/binaries/main/*/*"
token: ${{ secrets.GH_TOKEN }} token: ${{ secrets.GH_TOKEN }}
@ -81,7 +81,7 @@ jobs:
with: with:
draft: true draft: true
allowUpdates: true allowUpdates: true
tag: "v3.6.0" tag: "v3.6.1"
artifacts: "desktop/build/compose/jars/*.jar,desktop/build/compose/binaries/main/*/*,android/build/outputs/apk/release/*signed.apk" artifacts: "desktop/build/compose/jars/*.jar,desktop/build/compose/binaries/main/*/*,android/build/outputs/apk/release/*signed.apk"
token: ${{ secrets.GH_TOKEN }} token: ${{ secrets.GH_TOKEN }}
@ -114,6 +114,6 @@ jobs:
with: with:
draft: true draft: true
allowUpdates: true allowUpdates: true
tag: "v3.6.0" tag: "v3.6.1"
artifacts: "desktop/build/compose/jars/*.jar,desktop/build/compose/binaries/main/*/*" artifacts: "desktop/build/compose/jars/*.jar,desktop/build/compose/binaries/main/*/*"
token: ${{ secrets.GH_TOKEN }} token: ${{ secrets.GH_TOKEN }}

View File

@ -26,9 +26,9 @@ import org.gradle.kotlin.dsl.getByType
object Versions { object Versions {
// App's Version (To be bumped at each update) // App's Version (To be bumped at each update)
const val versionName = "3.6.0" const val versionName = "3.6.1"
const val versionCode = 28 const val versionCode = 29
// Android // Android
const val minSdkVersion = 21 const val minSdkVersion = 21

View File

@ -25,6 +25,7 @@ androidxLifecycle = "2.4.0-alpha03"
[libraries] [libraries]
kotlin-kotlinGradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } kotlin-kotlinGradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
kotlin-serialization = { group = "org.jetbrains.kotlin", name = "kotlin-serialization", version.ref = "kotlin" } kotlin-serialization = { group = "org.jetbrains.kotlin", name = "kotlin-serialization", version.ref = "kotlin" }
kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", version.ref = "kotlin" }
kotlin-kotlinTestCommon = { group = "org.jetbrains.kotlin", name = "kotlin-test-common", version.ref = "kotlin" } kotlin-kotlinTestCommon = { group = "org.jetbrains.kotlin", name = "kotlin-test-common", version.ref = "kotlin" }
kotlin-kotlinTestJs = { group = "org.jetbrains.kotlin", name = "kotlin-test-js", version.ref = "kotlin" } kotlin-kotlinTestJs = { group = "org.jetbrains.kotlin", name = "kotlin-test-js", version.ref = "kotlin" }
kotlin-kotlinTestJunit = { group = "org.jetbrains.kotlin", name = "kotlin-test-junit", version.ref = "kotlin" } kotlin-kotlinTestJunit = { group = "org.jetbrains.kotlin", name = "kotlin-test-junit", version.ref = "kotlin" }

View File

@ -43,8 +43,7 @@ suspend inline fun HttpClient.getFinalUrl(
} }
} }
fun createHttpClient(enableNetworkLogs: Boolean = false) = HttpClient { fun createHttpClient(enableNetworkLogs: Boolean = false) = buildHttpClient {
buildHttpClient {
// https://github.com/Kotlin/kotlinx.serialization/issues/1450 // https://github.com/Kotlin/kotlinx.serialization/issues/1450
install(JsonFeature) { install(JsonFeature) {
serializer = KotlinxSerializer(globalJson) serializer = KotlinxSerializer(globalJson)
@ -71,10 +70,9 @@ fun createHttpClient(enableNetworkLogs: Boolean = false) = HttpClient {
} }
} }
} }
}
expect fun buildHttpClient(extraConfig: HttpClientConfig<*>.() -> Unit): HttpClient expect fun buildHttpClient(extraConfig: HttpClientConfig<*>.() -> Unit): HttpClient
/*Client Active Throughout App's Lifetime*/ /*Client Active Throughout App's Lifetime*/
@SharedImmutable @SharedImmutable
val ktorHttpClient = HttpClient {} private val ktorHttpClient = HttpClient {}

View File

@ -152,17 +152,15 @@ interface SoundCloudRequests {
suspend inline fun <reified T : Any> SoundCloudRequests.doAuthenticatedRequest(url: String): T { suspend inline fun <reified T : Any> SoundCloudRequests.doAuthenticatedRequest(url: String): T {
var clientID: String = SoundCloudRequests.CLIENT_ID var clientID: String = SoundCloudRequests.CLIENT_ID
return try { return try {
val data: String = httpClient.get(url) { httpClient.get(url) {
parameter("client_id", clientID) parameter("client_id", clientID)
} }
globalJson.decodeFromString(data)
} catch (e: ClientRequestException) { } catch (e: ClientRequestException) {
if (clientID != SoundCloudRequests.ALT_CLIENT_ID) { if (clientID != SoundCloudRequests.ALT_CLIENT_ID) {
clientID = SoundCloudRequests.ALT_CLIENT_ID clientID = SoundCloudRequests.ALT_CLIENT_ID
val data: String = httpClient.get(url) { return httpClient.get(url) {
parameter("client_id", clientID) parameter("client_id", clientID)
} }
return globalJson.decodeFromString(data)
} }
throw e throw e
} }

View File

@ -34,9 +34,11 @@ import com.shabinder.common.providers.youtube_to_mp3.requests.YoutubeMp3
import com.shabinder.common.utils.appendPadded import com.shabinder.common.utils.appendPadded
import io.github.shabinder.fuzzywuzzy.diffutils.FuzzySearch import io.github.shabinder.fuzzywuzzy.diffutils.FuzzySearch
import io.ktor.client.HttpClient import io.ktor.client.HttpClient
import io.ktor.client.request.header
import io.ktor.client.request.headers import io.ktor.client.request.headers
import io.ktor.client.request.post import io.ktor.client.request.post
import io.ktor.http.ContentType import io.ktor.http.ContentType
import io.ktor.http.HttpHeaders
import io.ktor.http.contentType import io.ktor.http.contentType
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonArray import kotlinx.serialization.json.JsonArray
@ -357,8 +359,8 @@ class YoutubeMusic constructor(
private suspend fun getYoutubeMusicResponse(query: String): SuspendableEvent<String, Throwable> = private suspend fun getYoutubeMusicResponse(query: String): SuspendableEvent<String, Throwable> =
SuspendableEvent { SuspendableEvent {
httpClient.post("${corsApi}https://music.youtube.com/youtubei/v1/search?alt=json&key=$apiKey") { httpClient.post("${corsApi}https://music.youtube.com/youtubei/v1/search?alt=json&key=$apiKey") {
contentType(ContentType.Application.Json)
headers { headers {
append(HttpHeaders.ContentType, ContentType.Application.Json.toString())
append("referer", "https://music.youtube.com/search") append("referer", "https://music.youtube.com/search")
} }
body = buildJsonObject { body = buildJsonObject {

View File

@ -0,0 +1 @@
- Fixed Response Parsing Error which leaded download failure.