Skip to content

Commit

Permalink
fix(Instagram): debug build
Browse files Browse the repository at this point in the history
  • Loading branch information
Udhayarajan committed Jun 30, 2023
1 parent ec54f16 commit c475e3c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ plugins {
}

group = "io.github.udhayarajan"
version = "5.5.7"
version = "5.5.8"
//Version Naming incremented if "<NEW_FEATURE_ADDED>.<WORKED_ON_BUG>.<BETA_VERSION_COUNT>"
//Priority on incrementing Feature > BugFix > Beta

Expand Down
8 changes: 4 additions & 4 deletions src/commonMain/kotlin/com/mugames/vidsnapkit/JsonExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fun JSONObject.getNullableJSONObject(name: String): JSONObject? = try {
fun JSONArray.getNullableJSONObject(index: Int): JSONObject? = try {
getJSONObject(index)
} catch (e: JSONException) {
logger.warn("${toString()} \nis only available")
logger.warn("keyIdx=$index ${toString()} \nis only available")
null
}

Expand All @@ -53,21 +53,21 @@ fun JSONArray.getNullableJSONArray(index: Int): JSONArray? = try {
fun JSONObject.getNullableJSONArray(name: String): JSONArray? = try {
getJSONArray(name)
} catch (e: JSONException) {
logger.warn("${toString()} \nis only available")
logger.warn("key =${name} ${toString()} \nis only available")
null
}

fun JSONObject.getNullableString(name: String): String? = try {
getString(name)
} catch (e: JSONException) {
logger.warn("${toString()} \nis only available")
logger.warn("key =${name} ${toString()} \nis only available")
null
}

fun JSONObject.getNullable(name: String): String? = try {
get(name).toString()
} catch (e: JSONException) {
logger.warn("${toString()} \nis only available")
logger.warn("key =${name} ${toString()} \nis only available")
null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ abstract class Extractor(

private suspend fun safeAnalyze() {
try {
if (inputUrl.contains("facebook") || inputUrl.contains("fb")) {
if (inputUrl.contains("facebook")) {
if (inputUrl.contains("instagram.com")) {
logger.info("Insta embedded FB post, redirecting to Instagram")
val instaURL = Pattern.compile("\\?.*?u=(.*?)&").matcher(inputUrl).run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Instagram internal constructor(url: String) : Extractor(url) {
if (res.status == HttpStatusCode.Found) {
val newLoc = res.headers["location"].toString()
logger.info("new loc = $newLoc")
val restrictedKeywords = listOf("privacy/checks", "challenge", "coig_restricted")
val restrictedKeywords = listOf("privacy/checks", "challenge", "coig_restricted", "accounts/login")
val containsRestrictedKeyword = restrictedKeywords.any { keyword ->
newLoc.contains(keyword, ignoreCase = true)
}
Expand Down Expand Up @@ -164,7 +164,7 @@ class Instagram internal constructor(url: String) : Extractor(url) {
if (!isCookieValid()) {
cookies = null
}
if (load?.get("forced") == true) {
if (load?.get("forced") == true && cookies != null) {
logger.info("direct ex as forced")
directExtraction()
return
Expand Down Expand Up @@ -250,8 +250,8 @@ class Instagram internal constructor(url: String) : Extractor(url) {
.getJSONArray("items")
)
} catch (e: JSONException) {
logger.info("direct ex as JSONException arises")
directExtraction()
onProgress(Result.Failed(Error.LoginRequired))
return
}
}

Expand Down

0 comments on commit c475e3c

Please sign in to comment.