From 5a229cd8cf16baee7ab9fb9ce7273aae94a212c1 Mon Sep 17 00:00:00 2001 From: AwkwardPeak7 <48650614+AwkwardPeak7@users.noreply.github.com> Date: Mon, 13 May 2024 20:18:19 +0500 Subject: [PATCH] Keyoapp: filter hidden images (#2980) * Keyoapp: filter hidden images * unused imports --- lib-multisrc/keyoapp/build.gradle.kts | 2 +- .../tachiyomi/multisrc/keyoapp/Keyoapp.kt | 25 ++++++------------- .../extension/en/kewnscans/KewnScans.kt | 11 +------- 3 files changed, 10 insertions(+), 28 deletions(-) diff --git a/lib-multisrc/keyoapp/build.gradle.kts b/lib-multisrc/keyoapp/build.gradle.kts index 9dce2478c..e2f11e9c1 100644 --- a/lib-multisrc/keyoapp/build.gradle.kts +++ b/lib-multisrc/keyoapp/build.gradle.kts @@ -2,4 +2,4 @@ plugins { id("lib-multisrc") } -baseVersionCode = 2 +baseVersionCode = 3 diff --git a/lib-multisrc/keyoapp/src/eu/kanade/tachiyomi/multisrc/keyoapp/Keyoapp.kt b/lib-multisrc/keyoapp/src/eu/kanade/tachiyomi/multisrc/keyoapp/Keyoapp.kt index 702a65de7..c1f5f2675 100644 --- a/lib-multisrc/keyoapp/src/eu/kanade/tachiyomi/multisrc/keyoapp/Keyoapp.kt +++ b/lib-multisrc/keyoapp/src/eu/kanade/tachiyomi/multisrc/keyoapp/Keyoapp.kt @@ -223,9 +223,8 @@ abstract class Keyoapp( // Image list override fun pageListParse(document: Document): List { - 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() } } diff --git a/src/en/kewnscans/src/eu/kanade/tachiyomi/extension/en/kewnscans/KewnScans.kt b/src/en/kewnscans/src/eu/kanade/tachiyomi/extension/en/kewnscans/KewnScans.kt index 5aeef8fa6..c16e761b7 100644 --- a/src/en/kewnscans/src/eu/kanade/tachiyomi/extension/en/kewnscans/KewnScans.kt +++ b/src/en/kewnscans/src/eu/kanade/tachiyomi/extension/en/kewnscans/KewnScans.kt @@ -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 { - 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")