Skip to content

Commit 7d4244a

Browse files
committed
[Instagram] invalid url finder updated
1 parent 6312797 commit 7d4244a

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ plugins {
2424
}
2525

2626
group = "io.github.udhayarajan"
27-
version = "3.2.0"
27+
version = "3.3.0"
2828
//Version Naming incremented if "<NEW_FEATURE_ADDED>.<WORKED_ON_BUG>.<BETA_VERSION_COUNT>"
2929
//Priority on incrementing Feature > BugFix > Beta
3030
repositories {

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,19 @@ class Instagram internal constructor(url: String) : Extractor(url) {
7171
private suspend fun getUserID(): String? = cookies?.let { _ ->
7272

7373
getUserName()?.let {
74-
val response = HttpRequest(String.format(PROFILE_API, it), headers).getResponse()
75-
if (!isAccessible(JSONObject(response))) {
76-
onProgress(Result.Failed(Error.InvalidCookies))
74+
val response = HttpRequest(String.format(PROFILE_API, it), headers).getResponse()?.toJSONObject() ?: run {
75+
clientRequestError()
7776
return null
7877
}
79-
return response?.toJSONObject()?.getJSONObject("graphql")?.getJSONObject("user")?.getString("id") ?: run {
78+
if (response.toString() == "{}") {
8079
clientRequestError()
81-
null
80+
return null
81+
}
82+
if (!isAccessible(response)) {
83+
onProgress(Result.Failed(Error.InvalidCookies))
84+
return null
8285
}
86+
return response.getJSONObject("graphql")?.getJSONObject("user")?.getString("id")
8387
} ?: run {
8488
onProgress(Result.Failed(Error.InvalidUrl))
8589
}

0 commit comments

Comments
 (0)