Skip to content

Commit 61be77e

Browse files
committed
add a few code to diagnosis the error
1 parent 760f211 commit 61be77e

3 files changed

Lines changed: 22 additions & 11 deletions

File tree

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ plugins {
2727
}
2828

2929
group = "io.github.udhayarajan"
30-
version = "5.3.8"
30+
version = "5.3.9"
3131
//Version Naming incremented if "<NEW_FEATURE_ADDED>.<WORKED_ON_BUG>.<BETA_VERSION_COUNT>"
3232
//Priority on incrementing Feature > BugFix > Beta
3333

src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Instagram.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ class Instagram internal constructor(url: String) : Extractor(url) {
5252

5353
private suspend fun isCookieValid(): Boolean {
5454
if (cookies.isNullOrEmpty()) return false
55-
val res = HttpRequest("https://www.instagram.com/accounts/login/", headers).getRawResponse(false)
55+
val res =
56+
HttpRequest("https://www.instagram.com/accounts/login/", headers).getRawResponse(false) ?: return false
5657
if (res.status == HttpStatusCode.Found) {
5758
val newLoc = res.headers["location"]!!
5859
val restrictedKeywords = listOf("privacy/checks", "challenge", "coig_restricted")

src/commonMain/kotlin/com/mugames/vidsnapkit/network/HttpRequestHelper.kt

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import java.util.regex.Pattern
3535
*/
3636
interface HttpInterface {
3737
suspend fun getData(url: String, headers: Hashtable<String, String>? = null): String?
38-
suspend fun getRawResponse(url: String, headers: Hashtable<String, String>? = null): HttpResponse
38+
suspend fun getRawResponse(url: String, headers: Hashtable<String, String>? = null): HttpResponse?
3939
suspend fun getSize(url: String, headers: Hashtable<String, String>? = null): Long
4040

4141
suspend fun postData(
@@ -173,17 +173,27 @@ class HttpInterfaceImpl(
173173
}
174174
}
175175

176-
override suspend fun getRawResponse(url: String, headers: Hashtable<String, String>?): HttpResponse {
177-
return client.get {
178-
url(url)
179-
headers?.let {
180-
if (it.isNotEmpty()) {
181-
headers {
182-
for ((key, value) in it)
183-
append(key, value)
176+
override suspend fun getRawResponse(url: String, headers: Hashtable<String, String>?): HttpResponse? {
177+
return try {
178+
client.get {
179+
url(url)
180+
headers?.let {
181+
if (it.isNotEmpty()) {
182+
headers {
183+
for ((key, value) in it)
184+
append(key, value)
185+
}
184186
}
185187
}
186188
}
189+
} catch (e: Exception) {
190+
var x = false
191+
client.config { x = followRedirects }
192+
logger.error(
193+
"getRawResponse() url=${url} header=${headers.toString()} clientRedirection=${x} Generic exception:",
194+
e
195+
)
196+
null
187197
}
188198
}
189199

0 commit comments

Comments
 (0)