mirror of
https://github.com/Shabinder/SpotiFlyer.git
synced 2024-11-22 17:14:32 +01:00
Youtube Mp3 Link Fetching Fixed for Native
This commit is contained in:
parent
c278d6379a
commit
440210931b
@ -75,6 +75,8 @@ fun createHttpClient(enableNetworkLogs: Boolean = false) = HttpClient {
|
|||||||
install(JsonFeature) {
|
install(JsonFeature) {
|
||||||
serializer = KotlinxSerializer()
|
serializer = KotlinxSerializer()
|
||||||
}
|
}
|
||||||
|
// WorkAround for Freezing
|
||||||
|
// Use httpClient.getData / httpClient.postData Extensions
|
||||||
/*install(JsonFeature) {
|
/*install(JsonFeature) {
|
||||||
serializer = KotlinxSerializer(
|
serializer = KotlinxSerializer(
|
||||||
Json {
|
Json {
|
||||||
|
@ -49,7 +49,6 @@ suspend inline fun <reified T: Any> HttpClient.postData(
|
|||||||
): T {
|
): T {
|
||||||
val response = post<HttpResponse> {
|
val response = post<HttpResponse> {
|
||||||
url.takeFrom(urlString)
|
url.takeFrom(urlString)
|
||||||
header(HttpHeaders.ContentType, ContentType.Application.Json)
|
|
||||||
block()
|
block()
|
||||||
}
|
}
|
||||||
val jsonBody = response.readText()
|
val jsonBody = response.readText()
|
||||||
|
@ -45,7 +45,7 @@ interface Yt1sMp3 {
|
|||||||
* Body Form= q:yt video link ,vt:format=mp3
|
* Body Form= q:yt video link ,vt:format=mp3
|
||||||
* */
|
* */
|
||||||
private suspend fun getKey(videoID: String): String {
|
private suspend fun getKey(videoID: String): String {
|
||||||
val response: JsonObject? = httpClient.postData("${corsApi}https://yt1s.com/api/ajaxSearch/index") {
|
val response: JsonObject? = httpClient.post("${corsApi}https://yt1s.com/api/ajaxSearch/index") {
|
||||||
body = FormDataContent(
|
body = FormDataContent(
|
||||||
Parameters.build {
|
Parameters.build {
|
||||||
append("q", "https://www.youtube.com/watch?v=$videoID")
|
append("q", "https://www.youtube.com/watch?v=$videoID")
|
||||||
@ -57,7 +57,7 @@ interface Yt1sMp3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun getConvertedMp3Link(videoID: String, key: String): JsonObject? {
|
private suspend fun getConvertedMp3Link(videoID: String, key: String): JsonObject? {
|
||||||
return httpClient.postData("${corsApi}https://yt1s.com/api/ajaxConvert/convert") {
|
return httpClient.post("${corsApi}https://yt1s.com/api/ajaxConvert/convert") {
|
||||||
body = FormDataContent(
|
body = FormDataContent(
|
||||||
Parameters.build {
|
Parameters.build {
|
||||||
append("vid", videoID)
|
append("vid", videoID)
|
||||||
|
Loading…
Reference in New Issue
Block a user