update TciConnector.kt
This commit is contained in:
1 file changed
+5
-3
@@ -26,7 +26,7 @@ class TciConnector : ServiceConnector {
|
||||
): CaptchaChallenge = withContext(Dispatchers.IO) {
|
||||
val cookieJar = MutableCookieJar(TciCookieCodec.decode(secret.cookieJar))
|
||||
val client = HttpClients.withCookieJar(cookieJar)
|
||||
val panelHtml = client.newCall(browserGet("$BASE_URL/panel")).execute().use { response ->
|
||||
val panelHtml = client.newCall(browserGet(PANEL_URL)).execute().use { response ->
|
||||
if (!response.isSuccessful) {
|
||||
throw response.toRefreshException("TCI panel request failed")
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class TciConnector : ServiceConnector {
|
||||
secret
|
||||
}
|
||||
|
||||
val panelHtml = client.newCall(browserGet("$BASE_URL/panel")).execute().use { response ->
|
||||
val panelHtml = client.newCall(browserGet(PANEL_URL)).execute().use { response ->
|
||||
if (!response.isSuccessful) {
|
||||
throw response.toRefreshException("TCI panel request failed")
|
||||
}
|
||||
@@ -148,12 +148,14 @@ class TciConnector : ServiceConnector {
|
||||
private fun okhttp3.Response.toRefreshException(prefix: String): RefreshException {
|
||||
val errorCode = when (code) {
|
||||
401, 403 -> RefreshErrorCode.SESSION_EXPIRED
|
||||
else -> RefreshErrorCode.NETWORK
|
||||
in 500..599 -> RefreshErrorCode.INVALID_RESPONSE
|
||||
else -> RefreshErrorCode.PARSER_CHANGED
|
||||
}
|
||||
return RefreshException(errorCode, "$prefix (${this.code}).")
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val BASE_URL = "https://internet.tci.ir"
|
||||
private const val PANEL_URL = "$BASE_URL/panel/"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user