Imperfect Comics: Fixed image parsing (#10576)
This commit is contained in:
parent
0b177c3183
commit
febdab05c1
|
@ -19,34 +19,40 @@ import org.jsoup.nodes.Document
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
class ImperfectComics : Madara("Imperfect Comics", "https://imperfectcomic.com", "en", SimpleDateFormat("yyyy-MM-dd")) {
|
class ImperfectComics : Madara("Imperfect Comics", "https://imperfectcomic.com", "en", SimpleDateFormat("yyyy-MM-dd")) {
|
||||||
|
|
||||||
override val useNewChapterEndpoint: Boolean = true
|
override val useNewChapterEndpoint: Boolean = true
|
||||||
|
|
||||||
override val client: OkHttpClient = super.client.newBuilder()
|
override val client: OkHttpClient = network.cloudflareClient.newBuilder()
|
||||||
|
.connectTimeout(10, TimeUnit.SECONDS)
|
||||||
|
.readTimeout(30, TimeUnit.SECONDS)
|
||||||
.addInterceptor(::imageIntercept)
|
.addInterceptor(::imageIntercept)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
override fun pageListParse(document: Document): List<Page> {
|
override fun pageListParse(document: Document): List<Page> {
|
||||||
val mangaId = document.select("#manga-reading-nav-head").attr("data-id")
|
val mangaId = document.select("#manga-reading-nav-head").attr("data-id")
|
||||||
val chapterId = document.select("#wp-manga-current-chap").attr("data-id")
|
val chapterId = document.select("#wp-manga-current-chap").attr("data-id")
|
||||||
val mangaRegex = """data-id=\"$mangaId\"(?:.|\n)*?(?=\})""".toRegex()
|
val mangaRegex = """div\[data-id=\"$mangaId\"(?:.|\n)*?(?=\})""".toRegex()
|
||||||
val chapterRegex = """data-id=\"$chapterId\"(?:.|\n)*?(?=\})""".toRegex()
|
val chapterRegex = """input\[data-id=\"$chapterId\"(?:.|\n)*?(?=\})""".toRegex()
|
||||||
val css = document.selectFirst("#wp-custom-css").html()
|
val css = document.selectFirst("#wp-custom-css").html()
|
||||||
val props = mangaRegex.find(css).let { mId ->
|
|
||||||
mId?.value ?: chapterRegex.find(css).let { cId ->
|
//Checking for chapter first to handle mirrored manga with specific un-mirrored chapters
|
||||||
cId?.value ?: ""
|
val props = chapterRegex.find(css).let { cId ->
|
||||||
|
cId?.value ?: mangaRegex.find(css).let { mId ->
|
||||||
|
mId?.value ?: ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
countViews(document)
|
countViews(document)
|
||||||
|
|
||||||
return document.select(pageListParseSelector).mapIndexed { index, element ->
|
return document.select(pageListParseSelector).mapIndexed { index, element ->
|
||||||
val imageUrl = element.selectFirst("img")?.absUrl("src")!!
|
val imageUrl = element.selectFirst("img")?.let {
|
||||||
.toHttpUrlOrNull()!!.newBuilder()
|
it.absUrl(if (it.hasAttr("data-src")) "data-src" else "src")
|
||||||
|
}!!.toHttpUrlOrNull()!!.newBuilder()
|
||||||
|
|
||||||
if (props.contains("transform"))
|
if (props.contains("transform: scaleX(-1)"))
|
||||||
imageUrl.addQueryParameter("mirror", "1")
|
imageUrl.addQueryParameter("mirror", "1")
|
||||||
if (props.contains("invert"))
|
if (props.contains("invert"))
|
||||||
imageUrl.addQueryParameter("invert", "1")
|
imageUrl.addQueryParameter("invert", "1")
|
||||||
|
|
|
@ -119,7 +119,7 @@ class MadaraGenerator : ThemeSourceGenerator {
|
||||||
SingleLang("Ichirin No Hana Yuri", "https://ichirinnohanayuri.com.br", "pt-BR", overrideVersionCode = 3),
|
SingleLang("Ichirin No Hana Yuri", "https://ichirinnohanayuri.com.br", "pt-BR", overrideVersionCode = 3),
|
||||||
SingleLang("Ikifeng", "https://ikifeng.com", "es", isNsfw = true),
|
SingleLang("Ikifeng", "https://ikifeng.com", "es", isNsfw = true),
|
||||||
SingleLang("Immortal Updates", "https://immortalupdates.com", "en", overrideVersionCode = 2),
|
SingleLang("Immortal Updates", "https://immortalupdates.com", "en", overrideVersionCode = 2),
|
||||||
SingleLang("Imperfect Comics", "https://imperfectcomic.com", "en", overrideVersionCode = 3),
|
SingleLang("Imperfect Comics", "https://imperfectcomic.com", "en", overrideVersionCode = 4),
|
||||||
SingleLang("Império Scans", "https://imperioscans.com.br", "pt-BR", className = "ImperioScans", overrideVersionCode = 1),
|
SingleLang("Império Scans", "https://imperioscans.com.br", "pt-BR", className = "ImperioScans", overrideVersionCode = 1),
|
||||||
SingleLang("InfraFandub", "https://infrafandub.xyz", "es"),
|
SingleLang("InfraFandub", "https://infrafandub.xyz", "es"),
|
||||||
SingleLang("Inmortal Scan", "https://manga.mundodrama.site", "es"),
|
SingleLang("Inmortal Scan", "https://manga.mundodrama.site", "es"),
|
||||||
|
|
Loading…
Reference in New Issue