Skip to content

Commit

Permalink
fix(General): Redirection issue fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Udhayarajan committed Jun 27, 2023
1 parent 807e5a1 commit a73aee7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 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.3.12"
version = "5.3.13"
//Version Naming incremented if "<NEW_FEATURE_ADDED>.<WORKED_ON_BUG>.<BETA_VERSION_COUNT>"
//Priority on incrementing Feature > BugFix > Beta

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ class Instagram internal constructor(url: String) : Extractor(url) {
return true
}
}
if (res.status == HttpStatusCode.OK) {
if (res.call.request.url.toString() == "https://www.instagram.com/") {
return true
}
}
logger.info("Oops!, Cookie is invalid so removing it from header")
return false
}
Expand Down Expand Up @@ -212,7 +217,6 @@ class Instagram internal constructor(url: String) : Extractor(url) {
}



private suspend fun extractInfoShared(page: String) {
if (page == "{error:\"Invalid Cookies\"}") {
onProgress(Result.Failed(Error.LoginRequired))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class HttpRequest(
}

private fun createClient(requiresRedirection: Boolean = true): HttpInterface {
return HttpInterfaceImpl(clientGenerator().apply { config { followRedirects = requiresRedirection } })
return HttpInterfaceImpl(clientGenerator().config { followRedirects = requiresRedirection })
}

/**
Expand All @@ -66,7 +66,7 @@ class HttpRequest(
fun setClient(
clientGenerator: () -> HttpClient,
prefixUrl: String = "",
headers: Hashtable<String, String>? = null
headers: Hashtable<String, String>? = null,
) {
this.prefixUrl = prefixUrl
this.clientGenerator = clientGenerator
Expand Down Expand Up @@ -114,7 +114,10 @@ class HttpRequest(
}

suspend fun getRawResponse(needsRedirection: Boolean = true, useCustomClient: Boolean = true) =
(if (useCustomClient) createClient(needsRedirection) else defaultClient(needsRedirection)).getRawResponse(getUrl(), getHeader())
(if (useCustomClient) createClient(needsRedirection) else defaultClient(needsRedirection)).getRawResponse(
getUrl(),
getHeader()
)

suspend fun isAvailable(useCustomClient: Boolean = true): Boolean =
withContext(Dispatchers.IO) {
Expand Down

0 comments on commit a73aee7

Please sign in to comment.