MangasNoSekai: Fix chapter list (#1431)

cat and mouse
This commit is contained in:
Rolando Lecca 2024-02-20 12:42:25 -05:00 committed by Draff
parent 921649ff76
commit 8737cc41f2
2 changed files with 16 additions and 24 deletions

View File

@ -3,7 +3,7 @@ ext {
extClass = '.MangasNoSekai' extClass = '.MangasNoSekai'
themePkg = 'madara' themePkg = 'madara'
baseUrl = 'https://mangasnosekai.com' baseUrl = 'https://mangasnosekai.com'
overrideVersionCode = 6 overrideVersionCode = 7
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -188,35 +188,27 @@ class MangasNoSekai : Madara(
return POST("$baseUrl/wp-admin/admin-ajax.php", xhrHeaders, form) return POST("$baseUrl/wp-admin/admin-ajax.php", xhrHeaders, form)
} }
private val altChapterListSelector = "div.wp-manga-chapter" private val altChapterListSelector = "body > div > div"
override fun chapterListParse(response: Response): List<SChapter> { override fun chapterListParse(response: Response): List<SChapter> {
val document = response.asJsoup() val document = response.asJsoup()
launchIO { countViews(document) } launchIO { countViews(document) }
val mangaUrl = document.location().removeSuffix("/") val mangaId = document.selectFirst("div.tab-summary > script:containsData(manga_id)")?.data()
?.let { MANGA_ID_REGEX.find(it)?.groupValues?.get(1) }
?: throw Exception("No se pudo obtener el id del manga")
var xhrRequest = xhrChaptersRequest(mangaUrl) val chapterElements = mutableListOf<Element>()
var xhrResponse = client.newCall(xhrRequest).execute() var page = 1
do {
val xhrRequest = altChapterRequest(mangaId, page)
val xhrResponse = client.newCall(xhrRequest).execute()
val xhrDocument = xhrResponse.asJsoup()
chapterElements.addAll(xhrDocument.select(altChapterListSelector))
page++
} while (xhrDocument.select(altChapterListSelector).isNotEmpty())
val chapterElements = xhrResponse.asJsoup().select(chapterListSelector()) return chapterElements.map(::altChapterFromElement)
if (chapterElements.isEmpty()) {
val mangaId = document.selectFirst("div.tab-summary > script:containsData(manga_id)")?.data()
?.let { MANGA_ID_REGEX.find(it)?.groupValues?.get(1) }
?: throw Exception("No se pudo obtener el id del manga")
var page = 1
do {
xhrRequest = altChapterRequest(mangaId, page)
xhrResponse = client.newCall(xhrRequest).execute()
val xhrDocument = xhrResponse.asJsoup()
chapterElements.addAll(xhrDocument.select(altChapterListSelector))
page++
} while (xhrDocument.select(altChapterListSelector).isNotEmpty())
return chapterElements.map(::altChapterFromElement)
}
return chapterElements.map(::chapterFromElement)
} }
private fun altChapterFromElement(element: Element) = SChapter.create().apply { private fun altChapterFromElement(element: Element) = SChapter.create().apply {