From 1d97f337a588ebf986e8d26c409df2e925f5d021 Mon Sep 17 00:00:00 2001 From: Chopper <156493704+choppeh@users.noreply.github.com> Date: Tue, 6 Aug 2024 00:34:43 -0300 Subject: [PATCH] BlackoutComics: Fix loading pages (#4440) * Fix loading pages * Cleanup --- src/pt/blackoutcomics/build.gradle | 2 +- .../pt/blackoutcomics/BlackoutComics.kt | 23 +++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/pt/blackoutcomics/build.gradle b/src/pt/blackoutcomics/build.gradle index 8275920d5..a97ed9927 100644 --- a/src/pt/blackoutcomics/build.gradle +++ b/src/pt/blackoutcomics/build.gradle @@ -1,7 +1,7 @@ ext { extName = 'Blackout Comics' extClass = '.BlackoutComics' - extVersionCode = 4 + extVersionCode = 5 isNsfw = true } diff --git a/src/pt/blackoutcomics/src/eu/kanade/tachiyomi/extension/pt/blackoutcomics/BlackoutComics.kt b/src/pt/blackoutcomics/src/eu/kanade/tachiyomi/extension/pt/blackoutcomics/BlackoutComics.kt index ee22354ca..7496be994 100644 --- a/src/pt/blackoutcomics/src/eu/kanade/tachiyomi/extension/pt/blackoutcomics/BlackoutComics.kt +++ b/src/pt/blackoutcomics/src/eu/kanade/tachiyomi/extension/pt/blackoutcomics/BlackoutComics.kt @@ -16,6 +16,7 @@ import okhttp3.Response import org.jsoup.nodes.Document import org.jsoup.nodes.Element import rx.Observable +import java.io.IOException import java.text.SimpleDateFormat import java.util.Locale @@ -31,6 +32,14 @@ class BlackoutComics : ParsedHttpSource() { override val client by lazy { network.client.newBuilder() + .addInterceptor { chain -> + val response = chain.proceed(chain.request()) + val request = response.request + if (request.url.pathSegments.contains("login")) { + throw IOException("Faça o login na WebView para acessar o contéudo") + } + response + } .rateLimitHost(baseUrl.toHttpUrl(), 2) .build() } @@ -40,6 +49,7 @@ class BlackoutComics : ParsedHttpSource() { .add("Referer", "$baseUrl/") .add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8") .add("Accept-Language", "en-US,en;q=0.5") + .add("X-Requested-With", randomString((1..20).random())) // ============================== Popular =============================== override fun popularMangaRequest(page: Int) = GET("$baseUrl/ranking") @@ -155,8 +165,12 @@ class BlackoutComics : ParsedHttpSource() { // =============================== Pages ================================ override fun pageListParse(document: Document): List { - return document.select("div[class^=chapter-image] canvas[height][width][data-src^=/assets/obras/]").mapIndexed { index, item -> - Page(index, "", item.absUrl("data-src")) + return document.select("div[class*=cap] canvas[height][width]").mapIndexed { index, item -> + val attr = item.attributes() + .firstOrNull { it.value.contains("/assets/obras", ignoreCase = true) } + ?.key ?: throw Exception("Capitulo não pode ser obtido") + + Page(index, "", item.absUrl(attr)) } } @@ -170,6 +184,11 @@ class BlackoutComics : ParsedHttpSource() { .getOrNull() ?: 0L } + private fun randomString(length: Int): String { + val charPool = ('a'..'z') + ('A'..'Z') + return List(length) { charPool.random() }.joinToString("") + } + companion object { const val PREFIX_SEARCH = "id:"