mirror of
https://github.com/keiyoushi/extensions-source.git
synced 2024-11-22 10:22:47 +01:00
BlackoutComics: Fix loading pages (#4440)
* Fix loading pages * Cleanup
This commit is contained in:
parent
024d726a2d
commit
1d97f337a5
@ -1,7 +1,7 @@
|
|||||||
ext {
|
ext {
|
||||||
extName = 'Blackout Comics'
|
extName = 'Blackout Comics'
|
||||||
extClass = '.BlackoutComics'
|
extClass = '.BlackoutComics'
|
||||||
extVersionCode = 4
|
extVersionCode = 5
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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:"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user