From ebe881ee5190661c87234098ee9a9078d390175a Mon Sep 17 00:00:00 2001 From: dec05eba <66856951+dec05eba@users.noreply.github.com> Date: Mon, 19 Sep 2022 15:39:13 +0200 Subject: [PATCH] Fix mangakatana finding only 1 page (#13501) Try to find the actual variable that is used for images instead of using a hardcoded variable name. Closes #13486 --- src/en/mangakatana/build.gradle | 2 +- .../extension/en/mangakatana/MangaKatana.kt | 34 ++++++------------- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/en/mangakatana/build.gradle b/src/en/mangakatana/build.gradle index 470fb22da..787785bf6 100644 --- a/src/en/mangakatana/build.gradle +++ b/src/en/mangakatana/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'MangaKatana' pkgNameSuffix = 'en.mangakatana' extClass = '.MangaKatana' - extVersionCode = 8 + extVersionCode = 9 } apply from: "$rootDir/common.gradle" diff --git a/src/en/mangakatana/src/eu/kanade/tachiyomi/extension/en/mangakatana/MangaKatana.kt b/src/en/mangakatana/src/eu/kanade/tachiyomi/extension/en/mangakatana/MangaKatana.kt index 430d1c239..9a2e4fd98 100644 --- a/src/en/mangakatana/src/eu/kanade/tachiyomi/extension/en/mangakatana/MangaKatana.kt +++ b/src/en/mangakatana/src/eu/kanade/tachiyomi/extension/en/mangakatana/MangaKatana.kt @@ -179,8 +179,7 @@ class MangaKatana : ConfigurableSource, ParsedHttpSource() { date_upload = dateFormat.parse(element.select(".update_time").text())?.time ?: 0 } - private val imageArrayYtawRegex = Regex("""var ytaw=\[([^\[]*)]""") - private val imageArrayHtncRegex = Regex("""var htnc=\[([^\[]*)]""") + private val imageArrayNameRegex = Regex("""data-src['"],\s*(\w+)""") private val imageUrlRegex = Regex("""'([^']*)'""") // Page List @@ -191,28 +190,17 @@ class MangaKatana : ConfigurableSource, ParsedHttpSource() { } override fun pageListParse(document: Document): List { - val imageArrayYtaw = document.select("script:containsData(var ytaw)").firstOrNull()?.data() - ?.let { imageArrayYtawRegex.find(it)?.groupValues?.get(1) } - val imageArrayHtnc = document.select("script:containsData(var htnc)").firstOrNull()?.data() - ?.let { imageArrayHtncRegex.find(it)?.groupValues?.get(1) } + val imageScript = document.select("script:containsData(data-src)").firstOrNull()?.data() + ?: return emptyList() + val imageArrayName = imageArrayNameRegex.find(imageScript)?.groupValues?.get(1) + ?: return emptyList() + val imageArrayRegex = Regex("""var $imageArrayName=\[([^\[]*)]""") - val pagesYtaw = - imageArrayYtaw?.let { - imageUrlRegex.findAll(it).asIterable().mapIndexed { i, mr -> - Page(i, "", mr.groupValues[1]) - } - } ?: emptyList() - val pagesHtnc = - imageArrayHtnc?.let { - imageUrlRegex.findAll(it).asIterable().mapIndexed { i, mr -> - Page(i, "", mr.groupValues[1]) - } - } ?: emptyList() - - return if (pagesYtaw.size >= pagesHtnc.size) - pagesYtaw - else - pagesHtnc + return imageArrayRegex.find(imageScript)?.groupValues?.get(1)?.let { + imageUrlRegex.findAll(it).asIterable().mapIndexed { i, mr -> + Page(i, "", mr.groupValues[1]) + } + } ?: emptyList() } override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException("Not Used")