From 444caeafa755bd38f8ac9309035b291479fc419f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Wed, 3 Jan 2024 15:37:48 +0100 Subject: [PATCH] Version 2.3.3 --- build.gradle | 2 +- .../sdk/scrapper/interceptor/ErrorInterceptor.kt | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 63db9d6f..e784428b 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ ext { moshi = "1.13.0" } -version = "2.3.3-SNAPSHOT" +version = "2.3.3" group = "io.github.wulkanowy" nexusPublishing { diff --git a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/interceptor/ErrorInterceptor.kt b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/interceptor/ErrorInterceptor.kt index 76cf47dd..4bba58b5 100644 --- a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/interceptor/ErrorInterceptor.kt +++ b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/interceptor/ErrorInterceptor.kt @@ -59,6 +59,7 @@ internal class ErrorInterceptor( errorMessage.isNotBlank() -> throw BadCredentialsException(errorMessage) else -> logger.warn("Unexpected login page!") } + else -> throw BadCredentialsException(errorMessage) } } @@ -95,15 +96,24 @@ internal class ErrorInterceptor( when (doc.title()) { "Błąd" -> throw VulcanException(doc.body().text(), httpCode) "Błąd strony" -> throw VulcanException(doc.select(".errorMessage").text(), httpCode) - "Logowanie" -> throw AccountPermissionException(doc.select(".info-error-message-text").first()?.text().orEmpty()) + "Logowanie" -> throw AccountPermissionException( + buildString { + val newMessage = doc.select(".info-error-message-text").first()?.text().orEmpty() + val oldMessage = doc.select("div").last()?.ownText().orEmpty().split(" Jeśli")[0] + append(newMessage.ifBlank { oldMessage }) + }, + ) + "Login Service" -> { cookies.cookieStore.removeAll() // workaround for very strange (random) errors throw ScrapperException(doc.select("#MainDiv > div").text(), httpCode) } + "Połączenie zablokowane" -> throw ConnectionBlockedException(doc.body().text()) "Just a moment..." -> if (doc.select(".footer").text().contains("Cloudflare")) { throw ConnectionBlockedException(doc.select("#challenge-body-text").text()) } + "Przerwa" -> throw ServiceUnavailableException(doc.title()) "Przerwa techniczna" -> throw ServiceUnavailableException(doc.title()) "Strona nie została odnaleziona" -> throw ScrapperException(doc.title(), httpCode)