From 3ea088371b1fd1c1be6e2d8b0336eec2aea68fa0 Mon Sep 17 00:00:00 2001 From: devi Date: Sat, 18 Nov 2023 20:44:35 +0100 Subject: [PATCH] Minor daily update --- .../parsers/site/likemanga/LikeMangaParser.kt | 38 +++++++++++++++---- .../site/madara/es/ConsejoDeMatones.kt | 10 +++++ 2 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/es/ConsejoDeMatones.kt diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/likemanga/LikeMangaParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/likemanga/LikeMangaParser.kt index a6884cfb..98d38da5 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/likemanga/LikeMangaParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/likemanga/LikeMangaParser.kt @@ -3,6 +3,7 @@ package org.koitharu.kotatsu.parsers.site.likemanga import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.coroutineScope +import org.json.JSONObject import org.jsoup.nodes.Element import org.koitharu.kotatsu.parsers.MangaLoaderContext import org.koitharu.kotatsu.parsers.PagedMangaParser @@ -199,15 +200,36 @@ internal abstract class LikeMangaParser( override suspend fun getPages(chapter: MangaChapter): List { val fullUrl = chapter.url.toAbsoluteUrl(domain) val doc = webClient.httpGet(fullUrl).parseHtml() - return doc.select(".reading-detail img").map { img -> - val url = img.src() ?: img.parseFailed("Image src not found") - MangaPage( - id = generateUid(url), - url = url, - preview = null, - source = source, - ) + val testJson = doc.selectFirst("div.reading input#next_img_token") + if (testJson != null) { + val jsonRaw = testJson.attr("value").split(".")[1] + val jsonData = JSONObject(context.decodeBase64(jsonRaw).toString(Charsets.UTF_8)) + val jsonImg = context.decodeBase64(jsonData.getString("data")).toString(Charsets.UTF_8) + val images = jsonImg.replace("\\", "").replace("[", "").replace("]", "").replace("\"", "").split(",") + val cdn = doc.selectFirstOrThrow(".reading-detail img").src()?.substringBefore("manga/") + return images.map { img -> + val url = cdn + img + MangaPage( + id = generateUid(url), + url = url, + preview = null, + source = source, + ) + } + + } else { + return doc.select(".reading-detail img").map { img -> + val url = img.src() ?: img.parseFailed("Image src not found") + MangaPage( + id = generateUid(url), + url = url, + preview = null, + source = source, + ) + } + } + } private fun parseChapterDate(dateFormat: DateFormat, date: String?): Long { diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/es/ConsejoDeMatones.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/es/ConsejoDeMatones.kt new file mode 100644 index 00000000..4b8011f7 --- /dev/null +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/es/ConsejoDeMatones.kt @@ -0,0 +1,10 @@ +package org.koitharu.kotatsu.parsers.site.madara.es + +import org.koitharu.kotatsu.parsers.MangaLoaderContext +import org.koitharu.kotatsu.parsers.MangaSourceParser +import org.koitharu.kotatsu.parsers.model.MangaSource +import org.koitharu.kotatsu.parsers.site.madara.MadaraParser + +@MangaSourceParser("CONSEJODEMATONES", "ConsejoDeMatones", "es") +internal class ConsejoDeMatones(context: MangaLoaderContext) : + MadaraParser(context, MangaSource.CONSEJODEMATONES, "www.consejodematones.xyz")