BlackoutComics: Fix loading pages (#4440)

* Fix loading pages

* Cleanup
This commit is contained in:
Chopper 2024-08-06 00:34:43 -03:00 committed by GitHub
parent 024d726a2d
commit 1d97f337a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 3 deletions

View File

@ -1,7 +1,7 @@
ext { ext {
extName = 'Blackout Comics' extName = 'Blackout Comics'
extClass = '.BlackoutComics' extClass = '.BlackoutComics'
extVersionCode = 4 extVersionCode = 5
isNsfw = true isNsfw = true
} }

View File

@ -16,6 +16,7 @@ import okhttp3.Response
import org.jsoup.nodes.Document import org.jsoup.nodes.Document
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import rx.Observable import rx.Observable
import java.io.IOException
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Locale import java.util.Locale
@ -31,6 +32,14 @@ class BlackoutComics : ParsedHttpSource() {
override val client by lazy { override val client by lazy {
network.client.newBuilder() 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) .rateLimitHost(baseUrl.toHttpUrl(), 2)
.build() .build()
} }
@ -40,6 +49,7 @@ class BlackoutComics : ParsedHttpSource() {
.add("Referer", "$baseUrl/") .add("Referer", "$baseUrl/")
.add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8") .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("Accept-Language", "en-US,en;q=0.5")
.add("X-Requested-With", randomString((1..20).random()))
// ============================== Popular =============================== // ============================== Popular ===============================
override fun popularMangaRequest(page: Int) = GET("$baseUrl/ranking") override fun popularMangaRequest(page: Int) = GET("$baseUrl/ranking")
@ -155,8 +165,12 @@ class BlackoutComics : ParsedHttpSource() {
// =============================== Pages ================================ // =============================== Pages ================================
override fun pageListParse(document: Document): List<Page> { override fun pageListParse(document: Document): List<Page> {
return document.select("div[class^=chapter-image] canvas[height][width][data-src^=/assets/obras/]").mapIndexed { index, item -> return document.select("div[class*=cap] canvas[height][width]").mapIndexed { index, item ->
Page(index, "", item.absUrl("data-src")) 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 .getOrNull() ?: 0L
} }
private fun randomString(length: Int): String {
val charPool = ('a'..'z') + ('A'..'Z')
return List(length) { charPool.random() }.joinToString("")
}
companion object { companion object {
const val PREFIX_SEARCH = "id:" const val PREFIX_SEARCH = "id:"