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
This commit is contained in:
dec05eba 2022-09-19 15:39:13 +02:00 committed by GitHub
parent 1df19dcf90
commit ebe881ee51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 24 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'MangaKatana' extName = 'MangaKatana'
pkgNameSuffix = 'en.mangakatana' pkgNameSuffix = 'en.mangakatana'
extClass = '.MangaKatana' extClass = '.MangaKatana'
extVersionCode = 8 extVersionCode = 9
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -179,8 +179,7 @@ class MangaKatana : ConfigurableSource, ParsedHttpSource() {
date_upload = dateFormat.parse(element.select(".update_time").text())?.time ?: 0 date_upload = dateFormat.parse(element.select(".update_time").text())?.time ?: 0
} }
private val imageArrayYtawRegex = Regex("""var ytaw=\[([^\[]*)]""") private val imageArrayNameRegex = Regex("""data-src['"],\s*(\w+)""")
private val imageArrayHtncRegex = Regex("""var htnc=\[([^\[]*)]""")
private val imageUrlRegex = Regex("""'([^']*)'""") private val imageUrlRegex = Regex("""'([^']*)'""")
// Page List // Page List
@ -191,28 +190,17 @@ class MangaKatana : ConfigurableSource, ParsedHttpSource() {
} }
override fun pageListParse(document: Document): List<Page> { override fun pageListParse(document: Document): List<Page> {
val imageArrayYtaw = document.select("script:containsData(var ytaw)").firstOrNull()?.data() val imageScript = document.select("script:containsData(data-src)").firstOrNull()?.data()
?.let { imageArrayYtawRegex.find(it)?.groupValues?.get(1) } ?: return emptyList()
val imageArrayHtnc = document.select("script:containsData(var htnc)").firstOrNull()?.data() val imageArrayName = imageArrayNameRegex.find(imageScript)?.groupValues?.get(1)
?.let { imageArrayHtncRegex.find(it)?.groupValues?.get(1) } ?: return emptyList()
val imageArrayRegex = Regex("""var $imageArrayName=\[([^\[]*)]""")
val pagesYtaw = return imageArrayRegex.find(imageScript)?.groupValues?.get(1)?.let {
imageArrayYtaw?.let { imageUrlRegex.findAll(it).asIterable().mapIndexed { i, mr ->
imageUrlRegex.findAll(it).asIterable().mapIndexed { i, mr -> Page(i, "", mr.groupValues[1])
Page(i, "", mr.groupValues[1]) }
} } ?: emptyList()
} ?: 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
} }
override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException("Not Used") override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException("Not Used")