
* lib-randomua * NHentai: Random mobile ua * Madara random UA overhaul * MangaThemesia random UA overhaul * MangaHub random UA overhaul * build errors and warnings * remove preference from Constellar * change to singleton object * network.client * fix copy paste and chapter deep link * exit early * use data class and enum options * missing import * suggested changes Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> * re-add empty check to filters * convert to interceptor * update comment Co-authored-by: Alessandro Jean <14254807+alessandrojean@users.noreply.github.com> * update error message * initialize client by lazy * dont check on excluded Filters Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> * newlines * move preference helper function into lib * move preference helper function into lib x2 * move check to lib too * move defaultRandomUserAgentType to constructor * rename the interceptor * organize the interceptor and preference stuff in different files * hide custom ua setting when random ua is enabled * English Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> * catch specific exception Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> * setVisible() fresh stuff * setVisible() fresh stuff * change summary * workaround * Update error message Co-authored-by: Alessandro Jean <14254807+alessandrojean@users.noreply.github.com> * Update comment Co-authored-by: Alessandro Jean <14254807+alessandrojean@users.noreply.github.com> --------- Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Co-authored-by: Alessandro Jean <14254807+alessandrojean@users.noreply.github.com>
62 lines
2.3 KiB
Kotlin
62 lines
2.3 KiB
Kotlin
package eu.kanade.tachiyomi.extension.en.xcalibrscans
|
|
|
|
import android.util.Log
|
|
import eu.kanade.tachiyomi.multisrc.mangathemesia.MangaThemesia
|
|
import eu.kanade.tachiyomi.network.interceptor.rateLimit
|
|
import eu.kanade.tachiyomi.source.model.Page
|
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
|
import okhttp3.OkHttpClient
|
|
import org.jsoup.nodes.Document
|
|
import org.jsoup.nodes.Element
|
|
|
|
class xCaliBRScans : MangaThemesia("xCaliBR Scans", "https://xcalibrscans.com", "en") {
|
|
|
|
override val client: OkHttpClient = super.client.newBuilder()
|
|
.addInterceptor(AntiScrapInterceptor())
|
|
.rateLimit(2)
|
|
.build()
|
|
|
|
override val hasProjectPage = true
|
|
|
|
override fun pageListParse(document: Document): List<Page> {
|
|
document.selectFirst("div#readerarea .sword_box") ?: return super.pageListParse(document)
|
|
|
|
val imgUrls = mutableListOf<String>()
|
|
|
|
// Selects all direct descendant of "div#readerarea"
|
|
document.select("div#readerarea > *")
|
|
.forEach { element ->
|
|
when {
|
|
element.tagName() == "p" -> {
|
|
val imgUrl = element.selectFirst("img")!!.imgAttr()
|
|
imgUrls.add(imgUrl)
|
|
}
|
|
element.tagName() == "div" && element.hasClass("kage") -> {
|
|
parseAntiScrapScramble(element, imgUrls)
|
|
}
|
|
else -> {
|
|
Log.d("xCaliBR Scans", "Unknown element for page parsing $element")
|
|
}
|
|
}
|
|
}
|
|
|
|
return imgUrls.mapIndexed { index, imageUrl -> Page(index, imageUrl = imageUrl) }
|
|
}
|
|
|
|
private fun parseAntiScrapScramble(element: Element, destination: MutableList<String>) {
|
|
element.select("div.sword")
|
|
.forEach { swordDiv ->
|
|
val imgUrls = swordDiv.select("img").map { it.imgAttr() }
|
|
val urls = imgUrls.joinToString(AntiScrapInterceptor.IMAGE_URLS_SEPARATOR)
|
|
val url = baseUrl.toHttpUrl()
|
|
.newBuilder()
|
|
.addQueryParameter("urls", urls)
|
|
.fragment(AntiScrapInterceptor.ANTI_SCRAP_FRAGMENT)
|
|
.build()
|
|
.toString()
|
|
|
|
destination.add(url)
|
|
}
|
|
}
|
|
}
|