Keyoapp: filter hidden images (#2980)

* Keyoapp: filter hidden images

* unused imports
This commit is contained in:
AwkwardPeak7 2024-05-13 20:18:19 +05:00 committed by Draff
parent dc225dba18
commit 5a229cd8cf
3 changed files with 10 additions and 28 deletions

View File

@ -2,4 +2,4 @@ plugins {
id("lib-multisrc")
}
baseVersionCode = 2
baseVersionCode = 3

View File

@ -223,9 +223,8 @@ abstract class Keyoapp(
// Image list
override fun pageListParse(document: Document): List<Page> {
return document.select("#pages > img").map {
val index = it.attr("count").toInt()
Page(index, document.location(), it.imgAttr("150"))
return document.select("#pages > img:not(.hidden)").mapIndexed { index, img ->
Page(index, document.location(), img.imgAttr())
}
}
@ -234,31 +233,23 @@ abstract class Keyoapp(
// Utilities
// From mangathemesia
protected fun Element.imgAttr(width: String): String {
private fun Element.imgAttr(): String {
val url = when {
hasAttr("data-lazy-src") -> attr("abs:data-lazy-src")
hasAttr("data-src") -> attr("abs:data-src")
else -> attr("abs:src")
}
return url.toHttpUrl()
.newBuilder()
.addQueryParameter("w", width)
.build()
.toString()
return url
}
private fun Element.getImageUrl(selector: String): String? {
return this.selectFirst(selector)?.let {
it.attr("style")
return this.selectFirst(selector)?.let { element ->
element.attr("style")
.substringAfter(":url(", "")
.substringBefore(")", "")
.takeIf { it.isNotEmpty() }
?.toHttpUrlOrNull()?.let {
it.newBuilder()
.setQueryParameter("w", "480")
.build()
.toString()
}
?.toHttpUrlOrNull()?.newBuilder()?.setQueryParameter("w", "480")?.build()
?.toString()
}
}

View File

@ -1,14 +1,5 @@
package eu.kanade.tachiyomi.extension.en.kewnscans
import eu.kanade.tachiyomi.multisrc.keyoapp.Keyoapp
import eu.kanade.tachiyomi.source.model.Page
import org.jsoup.nodes.Document
class KewnScans : Keyoapp("Kewn Scans", "https://kewnscans.org", "en") {
override fun pageListParse(document: Document): List<Page> {
return document.select("#pages > img:not(.hidden)").map {
val index = it.attr("count").toInt()
Page(index, document.location(), it.imgAttr("150"))
}
}
}
class KewnScans : Keyoapp("Kewn Scans", "https://kewnscans.org", "en")