[MadTheme] Fix pages parsing #701

This commit is contained in:
2024-04-20 16:53:23 +03:00
parent fb387dbcd9
commit 7829a2ad3b
2 changed files with 15 additions and 1 deletions

View File

@@ -16,4 +16,3 @@ dependencyResolutionManagement {
rootProject.name = 'kotatsu-parsers'
include 'kotatsu-parsers-ksp'

View File

@@ -226,6 +226,21 @@ internal abstract class MadthemeParser(
val fullUrl = chapter.url.toAbsoluteUrl(domain)
val doc = webClient.httpGet(fullUrl).parseHtml()
val regexPages = Regex("chapImages\\s*=\\s*'(.*)'")
val pages = doc.select("script").firstNotNullOfOrNull { script ->
regexPages.find(script.html())?.groupValues?.getOrNull(1)
}?.split(',')
if (pages != null) {
return pages.map { url ->
MangaPage(
id = generateUid(url),
url = url,
preview = null,
source = source,
)
}
}
// fallback to html parisng
return doc.select(selectPage).map { img ->
val url = img.src()?.toRelativeUrl(domain) ?: img.parseFailed("Image src not found")
MangaPage(