From 40a72849946fd2692d645e2075c0bd267c7a5516 Mon Sep 17 00:00:00 2001 From: udhayarajan Date: Sun, 23 Jul 2023 18:09:14 +0530 Subject: [PATCH 1/2] fix(General): patch for last version --- build.gradle.kts | 2 +- .../mugames/vidsnapkit/extractor/Extractor.kt | 29 ++-- .../mugames/vidsnapkit/extractor/Facebook.kt | 4 +- .../mugames/vidsnapkit/extractor/Instagram.kt | 11 +- .../com/mugames/vidsnapkit/extractor/Likee.kt | 7 +- .../mugames/vidsnapkit/extractor/Twitch.kt | 5 +- .../mugames/vidsnapkit/extractor/Twitter.kt | 5 +- .../vidsnapkit/network/HttpRequestService.kt | 10 +- .../network/HttpRequestServiceImpl.kt | 159 +++++++++--------- 9 files changed, 126 insertions(+), 106 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 58df0549..ab29e357 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -28,7 +28,7 @@ plugins { } group = "io.github.udhayarajan" -version = "5.6.8" +version = "5.6.9" // Version Naming incremented if ".." // Priority on incrementing Feature > BugFix > Beta diff --git a/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Extractor.kt b/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Extractor.kt index ef8ed4e7..09bdb006 100644 --- a/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Extractor.kt +++ b/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Extractor.kt @@ -100,7 +100,11 @@ abstract class Extractor( protected var headers: Hashtable = Hashtable() private val store = AcceptAllCookiesStorage() - protected var httpRequestService = HttpRequestService.create(storage = store) + protected var httpRequestService = run { + val str = if (inputUrl.contains(Regex("/reels/audio/|tiktok"))) store else null + HttpRequestService.create(storage = str) + } + /** * If media is private just pass valid cookies to @@ -127,7 +131,8 @@ abstract class Extractor( */ fun setCustomClient(httpClient: HttpClient) { httpRequestService.close() - httpRequestService = HttpRequestService.create(httpClient, store) + val str = if (inputUrl.contains(Regex("/reels/audio/|tiktok"))) store else null + httpRequestService = HttpRequestService.create(httpClient, str) } /** @@ -245,7 +250,7 @@ abstract class Extractor( return sizes.awaitAll() } - protected fun clientRequestError(msg: String = "The request video page missing. If you find it as false kindly contact us") { + protected fun clientRequestError(msg: String = "error making request") { onProgress(Result.Failed(Error.NonFatalError(msg))) } @@ -267,22 +272,22 @@ abstract class Extractor( private fun getRandomInstagramUserAgent(): String { val userAgents = listOf( "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 " + - "Safari/537.36", + "Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 " + - "Safari/537.36", + "Safari/537.36", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) " + - "Chrome/74.0.3729.169 Safari/537.36", + "Chrome/74.0.3729.169 Safari/537.36", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 " + - "Safari/537.36", + "Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 " + - "Safari/537.36", + "Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 " + - "Safari/537.36", + "Safari/537.36", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 " + - "Safari/537.36", + "Safari/537.36", "Mozilla/5.0 (iPhone; CPU iPhone OS 12_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) " + - "Mobile/15E148 Instagram 105.0.0.11.118 (iPhone11,8; iOS 12_3_1; en_US; en-US; scale=2.00; " + - "828x1792; 165586599)" + "Mobile/15E148 Instagram 105.0.0.11.118 (iPhone11,8; iOS 12_3_1; en_US; en-US; scale=2.00; " + + "828x1792; 165586599)" ) return userAgents.random() } diff --git a/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Facebook.kt b/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Facebook.kt index e0316e64..2cc16594 100644 --- a/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Facebook.kt +++ b/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Facebook.kt @@ -226,7 +226,7 @@ class Facebook internal constructor(url: String) : Extractor(url) { } ?: apply { val uuid = "fb." + UUID.randomUUID().toString() + ".html" File(uuid).writeText(webPage) - onProgress(Result.Failed(Error.NonFatalError("This video can't be Downloaded, refer=$uuid"))) + onProgress(Result.Failed(Error.NonFatalError("Sorry! we can't see the page, refer=$uuid"))) } } @@ -561,7 +561,7 @@ class Facebook internal constructor(url: String) : Extractor(url) { videoData.get("original_width") .toString() + "x" + videoData.get("original_height") + "(" + s.uppercase() + ")", - ) + ) ) } return SUCCESS diff --git a/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Instagram.kt b/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Instagram.kt index b1e92939..04677526 100644 --- a/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Instagram.kt +++ b/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Instagram.kt @@ -178,10 +178,10 @@ class Instagram internal constructor(url: String) : Extractor(url) { private suspend fun extractMusicAssetInfo(assetInfo: JSONObject) { formats.title = assetInfo.getNullableString("title")?.ifEmpty { null } ?: assetInfo.getNullableString("subtitle") - ?.ifEmpty { null } ?: "Reels_audio ${assetInfo.getNullableString("display_artist")}" + ?.ifEmpty { null } ?: "Reels_audio ${assetInfo.getNullableString("display_artist")}" val imageUrl = assetInfo.run { getNullableString("cover_artwork_uri")?.ifEmpty { null } ?: getNullableString("cover_artwork_thumbnail_uri") - ?: getJSONObject("music_composition_info").getString("placeholder_profile_pic_url") + ?: getJSONObject("music_composition_info").getString("placeholder_profile_pic_url") } formats.imageData.add(ImageResource(imageUrl, Util.getResolutionFromUrl(imageUrl))) @@ -283,8 +283,8 @@ class Instagram internal constructor(url: String) : Extractor(url) { tempHeader.remove("User-Agent") tempHeader["X-Ig-App-Id"] = appId val res = httpRequestService.postRequest(AUDIO_API, tempHeader, audioPayload) - val metadata = res.toJSONObject().getJSONObject("metadata") - metadata.run { + val metadata = res?.toJSONObject()?.getJSONObject("metadata") + metadata?.run { getNullableJSONObject("original_sound_info")?.let { extractFromOriginalAudioInfo(it) } ?: getNullableJSONObject("music_info") ?.getJSONObject("music_asset_info") @@ -293,6 +293,9 @@ class Instagram internal constructor(url: String) : Extractor(url) { missingLogic() return } + } ?: run { + clientRequestError() + return } } else { // possibly user url diff --git a/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Likee.kt b/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Likee.kt index 82a7b5f6..fd45cd2a 100644 --- a/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Likee.kt +++ b/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Likee.kt @@ -46,8 +46,11 @@ class Likee internal constructor(url: String) : Extractor(url) { } val response = httpRequestService.postRequest(GET_VIDEO_INFO, hashMapOf("postIds" to postId).toHashtable()) val responseData = - response.toJSONObject() - .getJSONObject("data") + response?.toJSONObject() + ?.getJSONObject("data") ?: run { + clientRequestError() + return + } responseData.getJSONArray("videoList")?.let { extractVideoList(it) } ?: run { diff --git a/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Twitch.kt b/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Twitch.kt index 90ec2eca..aa0f0c50 100644 --- a/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Twitch.kt +++ b/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Twitch.kt @@ -63,7 +63,10 @@ class Twitch internal constructor(url: String) : Extractor(url) { "{\"query\":\"{clip(slug:\\\"%s\\\"){broadcaster{displayName}createdAt curator{displayName id}durationSeconds id tiny:thumbnailURL(width:86,height:45)small:thumbnailURL(width:260,height:147)medium:thumbnailURL(width:480,height:272)title videoQualities{frameRate quality sourceURL}viewCount}}\"}", id ) - val response = httpRequestService.postRequest("https://gql.twitch.tv/gql", headers = headers) + val response = httpRequestService.postRequest("https://gql.twitch.tv/gql", headers = headers) ?: run { + clientRequestError() + return localFormats + } val clip = response.toJSONObject().getJSONObject("data").getJSONObject("clip") localFormats.imageData.add(ImageResource(clip.getString("medium"), "medium")) val videoQualities = clip.getJSONArray("videoQualities") diff --git a/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Twitter.kt b/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Twitter.kt index bf3e4b68..257bb552 100644 --- a/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Twitter.kt +++ b/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Twitter.kt @@ -70,7 +70,10 @@ class Twitter internal constructor(url: String) : Extractor(url) { } private suspend fun getToken() { - val response = httpRequestService.postRequest(base_url + "guest/activate.json", headers = headers) + val response = httpRequestService.postRequest(base_url + "guest/activate.json", headers = headers) ?: run { + clientRequestError("post request fails") + return + } headers["x-guest-token"] = response.toJSONObject().getString("guest_token") if (inputUrl.contains("status")) extractVideo() if (inputUrl.contains("broadcasts")) extractBroadcasts() diff --git a/src/commonMain/kotlin/com/mugames/vidsnapkit/network/HttpRequestService.kt b/src/commonMain/kotlin/com/mugames/vidsnapkit/network/HttpRequestService.kt index 1763fb96..db9df0c2 100644 --- a/src/commonMain/kotlin/com/mugames/vidsnapkit/network/HttpRequestService.kt +++ b/src/commonMain/kotlin/com/mugames/vidsnapkit/network/HttpRequestService.kt @@ -32,7 +32,7 @@ interface HttpRequestService { suspend fun getResponse( url: String, headers: - Hashtable? = null, + Hashtable? = null, ): String? /** @@ -60,7 +60,7 @@ interface HttpRequestService { url: String, headers: Hashtable? = null, postData: Hashtable? = null, - ): String + ): String? suspend fun postRawResponse( url: String, @@ -85,11 +85,9 @@ interface HttpRequestService { client.config { install(HttpTimeout) { socketTimeoutMillis = 13_000 - requestTimeoutMillis = 13_000 - connectTimeoutMillis = 13_000 } - install(HttpCookies) { - if (storage != null) { + if (storage != null) { + install(HttpCookies) { this.storage = storage } } diff --git a/src/commonMain/kotlin/com/mugames/vidsnapkit/network/HttpRequestServiceImpl.kt b/src/commonMain/kotlin/com/mugames/vidsnapkit/network/HttpRequestServiceImpl.kt index 6706a72f..73ec4fea 100644 --- a/src/commonMain/kotlin/com/mugames/vidsnapkit/network/HttpRequestServiceImpl.kt +++ b/src/commonMain/kotlin/com/mugames/vidsnapkit/network/HttpRequestServiceImpl.kt @@ -53,66 +53,69 @@ class HttpRequestServiceImpl(private val client: HttpClient) : HttpRequestServic override suspend fun getResponse( url: String, headers: Hashtable?, - ): String? = try { - client.get { - url(url) - headers?.let { - if (it.isNotEmpty()) { - headers { - for ((key, value) in it) append(key, value) + ): String? { + return try { + client.get { + url(url) + headers?.let { + if (it.isNotEmpty()) { + headers { + for ((key, value) in it) append(key, value) + } } } + }.run { + if (status == HttpStatusCode.OK) { + bodyAsText() + } else if (status in redirectionStatusCode) { + getLastPossibleRedirectedResponse(this, headers).bodyAsText() + } else if (url.contains("instagram") && status == HttpStatusCode.InternalServerError) { + "{error:\"Invalid Cookies\"}" + } else if (status == HttpStatusCode.TooManyRequests) { + logger.warn("Unhandled in getData() TooManyRequest for url=$url with headers=$headers & response=${bodyAsText()}") + "429" + } else { + val body = bodyAsText() + logger.warn( + "Unhandled in getData() status code=$status for url=$url with headers=$headers &\n response=${ + body.substring( + min(body.length, 2000) + ) + }" + ) + null + } } - }.run { - if (status == HttpStatusCode.OK) { - bodyAsText() - } else if (status in redirectionStatusCode) { - getLastPossibleRedirectedResponse(this, headers).bodyAsText() - } else if (url.contains("instagram") && status == HttpStatusCode.InternalServerError) { + } catch (e: ClientRequestException) { + logger.error("getData() url=$url header=$headers ClientRequestException:", e) + null + } catch (e: SSLPeerUnverifiedException) { + logger.error("getData() url=$url header=$headers SSLPeerUnverifiedException ${e.message}") + throw ProxyException(e) + } catch (e: SocketTimeoutException) { + logger.error("getData() url=$url header=$headers SocketTimeoutException ${e.message}") + throw ProxyException(e) + } catch (e: SocketException) { + logger.error("getData() url=$url header=$headers SocketException ${e.message}") + throw ProxyException(e) + } catch (e: SSLHandshakeException) { + logger.error("getData() url=$url header=$headers SLLHandShakeException ${e.message}") + throw ProxyException(e) + } catch (e: SendCountExceedException) { + if (url.contains("instagram") && headers?.containsKey("Cookie") == true) { "{error:\"Invalid Cookies\"}" - } else if (status == HttpStatusCode.TooManyRequests) { - logger.warn("Unhandled in getData() TooManyRequest for url=$url with headers=$headers & response=${bodyAsText()}") - "429" } else { - val body = bodyAsText() - logger.warn( - "Unhandled in getData() status code=$status for url=$url with headers=$headers &\n response=${ - body.substring( - min(body.length, 2000) - ) - }" - ) - null + logger.error("getData() url=$url header=$headers SendCountExceedException:", e) + throw e } - } - } catch (e: ClientRequestException) { - logger.error("getData() url=$url header=$headers ClientRequestException:", e) - null - } catch (e: SSLPeerUnverifiedException) { - logger.error("getData() url=$url header=$headers SSLPeerUnverifiedException ${e.message}") - throw ProxyException(e) - } catch (e: SocketTimeoutException) { - logger.error("getData() url=$url header=$headers SocketTimeoutException ${e.message}") - throw ProxyException(e) - } catch (e: SocketException) { - logger.error("getData() url=$url header=$headers SocketException ${e.message}") - throw ProxyException(e) - } catch (e: SSLHandshakeException) { - logger.error("getData() url=$url header=$headers SLLHandShakeException ${e.message}") - throw ProxyException(e) - } catch (e: SendCountExceedException) { - if (url.contains("instagram") && headers?.containsKey("Cookie") == true) { - "{error:\"Invalid Cookies\"}" - } else { - logger.error("getData() url=$url header=$headers SendCountExceedException:", e) + } catch (e: Exception) { + if (e is TimeoutCancellationException || e is CancellationException) { + logger.error("getData() url=$url header=$headers Cancellation exception: ${e.message}") + return null + } else logger.error("getData() url=$url header=$headers Generic exception:", e) throw e } - } catch (e: Exception) { - if (e is TimeoutCancellationException || e is CancellationException) logger.error("getData() url=$url header=$headers Cancellation exception: ${e.message}") - else logger.error("getData() url=$url header=$headers Generic exception:", e) - throw e } - override suspend fun getRawResponse( url: String, headers: Hashtable?, @@ -196,33 +199,35 @@ class HttpRequestServiceImpl(private val client: HttpClient) : HttpRequestServic url: String, headers: Hashtable?, postData: Hashtable?, - ) = try { - client.post { - url(url) - headers?.let { - if (it.isNotEmpty()) headers { - for ((key, value) in it) append(key, value) + ): String? { + return try { + client.post { + url(url) + headers?.let { + if (it.isNotEmpty()) headers { + for ((key, value) in it) append(key, value) + } } - } - postData?.let { - setBody(TextContent(it.toJsonString(), ContentType.Application.Json)) - } - }.bodyAsText() - } catch (e: SocketTimeoutException) { - logger.error("postRequest() url=$url header=$headers SocketTimeoutException ${e.message}") - throw ProxyException(e) - } catch (e: SocketException) { - logger.error("postRequest() url=$url header=$headers SocketException ${e.message}") - throw ProxyException(e) - } catch (e: SSLHandshakeException) { - logger.error("postRequest() url=$url header=$headers SSLPeerUnverifiedException ${e.message}") - throw ProxyException(e) - } catch (e: SSLPeerUnverifiedException) { - logger.error("postRequest() url=$url header=$headers SSLPeerUnverifiedException ${e.message}") - throw ProxyException(e) - } catch (e: Exception) { - logger.error("postRequest() url=$url header=$headers & postRequest=$postData Error:", e) - throw e + postData?.let { + setBody(TextContent(it.toJsonString(), ContentType.Application.Json)) + } + }.bodyAsText() + } catch (e: SocketTimeoutException) { + logger.error("postRequest() url=$url header=$headers SocketTimeoutException ${e.message}") + throw ProxyException(e) + } catch (e: SocketException) { + logger.error("postRequest() url=$url header=$headers SocketException ${e.message}") + throw ProxyException(e) + } catch (e: SSLHandshakeException) { + logger.error("postRequest() url=$url header=$headers SSLPeerUnverifiedException ${e.message}") + throw ProxyException(e) + } catch (e: SSLPeerUnverifiedException) { + logger.error("postRequest() url=$url header=$headers SSLPeerUnverifiedException ${e.message}") + throw ProxyException(e) + } catch (e: Exception) { + logger.error("postRequest() url=$url header=$headers & postRequest=$postData Error:", e) + return null + } } override suspend fun postRawResponse( From e75f9331a59beda57d1119c75141ef8b0327ff07 Mon Sep 17 00:00:00 2001 From: udhayarajan Date: Sun, 23 Jul 2023 18:12:47 +0530 Subject: [PATCH 2/2] fix: lint --- .../mugames/vidsnapkit/extractor/Extractor.kt | 19 +++++++++---------- .../mugames/vidsnapkit/extractor/Facebook.kt | 2 +- .../mugames/vidsnapkit/extractor/Instagram.kt | 4 ++-- .../vidsnapkit/network/HttpRequestService.kt | 2 +- .../network/HttpRequestServiceImpl.kt | 6 +++--- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Extractor.kt b/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Extractor.kt index 09bdb006..2f028f6e 100644 --- a/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Extractor.kt +++ b/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Extractor.kt @@ -105,7 +105,6 @@ abstract class Extractor( HttpRequestService.create(storage = str) } - /** * If media is private just pass valid cookies to * extract list of [Formats] @@ -272,22 +271,22 @@ abstract class Extractor( private fun getRandomInstagramUserAgent(): String { val userAgents = listOf( "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 " + - "Safari/537.36", + "Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 " + - "Safari/537.36", + "Safari/537.36", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) " + - "Chrome/74.0.3729.169 Safari/537.36", + "Chrome/74.0.3729.169 Safari/537.36", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 " + - "Safari/537.36", + "Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 " + - "Safari/537.36", + "Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 " + - "Safari/537.36", + "Safari/537.36", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 " + - "Safari/537.36", + "Safari/537.36", "Mozilla/5.0 (iPhone; CPU iPhone OS 12_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) " + - "Mobile/15E148 Instagram 105.0.0.11.118 (iPhone11,8; iOS 12_3_1; en_US; en-US; scale=2.00; " + - "828x1792; 165586599)" + "Mobile/15E148 Instagram 105.0.0.11.118 (iPhone11,8; iOS 12_3_1; en_US; en-US; scale=2.00; " + + "828x1792; 165586599)" ) return userAgents.random() } diff --git a/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Facebook.kt b/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Facebook.kt index 2cc16594..442475e5 100644 --- a/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Facebook.kt +++ b/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Facebook.kt @@ -561,7 +561,7 @@ class Facebook internal constructor(url: String) : Extractor(url) { videoData.get("original_width") .toString() + "x" + videoData.get("original_height") + "(" + s.uppercase() + ")", - ) + ) ) } return SUCCESS diff --git a/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Instagram.kt b/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Instagram.kt index 04677526..913e60c7 100644 --- a/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Instagram.kt +++ b/src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Instagram.kt @@ -178,10 +178,10 @@ class Instagram internal constructor(url: String) : Extractor(url) { private suspend fun extractMusicAssetInfo(assetInfo: JSONObject) { formats.title = assetInfo.getNullableString("title")?.ifEmpty { null } ?: assetInfo.getNullableString("subtitle") - ?.ifEmpty { null } ?: "Reels_audio ${assetInfo.getNullableString("display_artist")}" + ?.ifEmpty { null } ?: "Reels_audio ${assetInfo.getNullableString("display_artist")}" val imageUrl = assetInfo.run { getNullableString("cover_artwork_uri")?.ifEmpty { null } ?: getNullableString("cover_artwork_thumbnail_uri") - ?: getJSONObject("music_composition_info").getString("placeholder_profile_pic_url") + ?: getJSONObject("music_composition_info").getString("placeholder_profile_pic_url") } formats.imageData.add(ImageResource(imageUrl, Util.getResolutionFromUrl(imageUrl))) diff --git a/src/commonMain/kotlin/com/mugames/vidsnapkit/network/HttpRequestService.kt b/src/commonMain/kotlin/com/mugames/vidsnapkit/network/HttpRequestService.kt index db9df0c2..21c7e1fa 100644 --- a/src/commonMain/kotlin/com/mugames/vidsnapkit/network/HttpRequestService.kt +++ b/src/commonMain/kotlin/com/mugames/vidsnapkit/network/HttpRequestService.kt @@ -32,7 +32,7 @@ interface HttpRequestService { suspend fun getResponse( url: String, headers: - Hashtable? = null, + Hashtable? = null, ): String? /** diff --git a/src/commonMain/kotlin/com/mugames/vidsnapkit/network/HttpRequestServiceImpl.kt b/src/commonMain/kotlin/com/mugames/vidsnapkit/network/HttpRequestServiceImpl.kt index 73ec4fea..d436c9ab 100644 --- a/src/commonMain/kotlin/com/mugames/vidsnapkit/network/HttpRequestServiceImpl.kt +++ b/src/commonMain/kotlin/com/mugames/vidsnapkit/network/HttpRequestServiceImpl.kt @@ -78,9 +78,9 @@ class HttpRequestServiceImpl(private val client: HttpClient) : HttpRequestServic val body = bodyAsText() logger.warn( "Unhandled in getData() status code=$status for url=$url with headers=$headers &\n response=${ - body.substring( - min(body.length, 2000) - ) + body.substring( + min(body.length, 2000) + ) }" ) null