From 404c86ac0906b480deaf2e7c4e30429c62bf6012 Mon Sep 17 00:00:00 2001 From: bapeey <90949336+bapeey@users.noreply.github.com> Date: Sun, 3 Nov 2024 06:41:37 -0500 Subject: [PATCH] Manhwa-Latino: Fix missing chapters (#5823) paginated chapter list --- src/es/manhwalatino/build.gradle | 2 +- .../extension/es/manhwalatino/ManhwaLatino.kt | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/es/manhwalatino/build.gradle b/src/es/manhwalatino/build.gradle index 0270d0933..2fd22ad19 100644 --- a/src/es/manhwalatino/build.gradle +++ b/src/es/manhwalatino/build.gradle @@ -3,7 +3,7 @@ ext { extClass = '.ManhwaLatino' themePkg = 'madara' baseUrl = 'https://manhwa-latino.com' - overrideVersionCode = 7 + overrideVersionCode = 8 isNsfw = true } diff --git a/src/es/manhwalatino/src/eu/kanade/tachiyomi/extension/es/manhwalatino/ManhwaLatino.kt b/src/es/manhwalatino/src/eu/kanade/tachiyomi/extension/es/manhwalatino/ManhwaLatino.kt index 0df63d345..8ea2bfcae 100644 --- a/src/es/manhwalatino/src/eu/kanade/tachiyomi/extension/es/manhwalatino/ManhwaLatino.kt +++ b/src/es/manhwalatino/src/eu/kanade/tachiyomi/extension/es/manhwalatino/ManhwaLatino.kt @@ -1,9 +1,14 @@ package eu.kanade.tachiyomi.extension.es.manhwalatino import eu.kanade.tachiyomi.multisrc.madara.Madara +import eu.kanade.tachiyomi.network.GET +import eu.kanade.tachiyomi.network.interceptor.rateLimitHost import eu.kanade.tachiyomi.source.model.SChapter +import eu.kanade.tachiyomi.util.asJsoup +import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.OkHttpClient +import okhttp3.Response import okhttp3.ResponseBody.Companion.toResponseBody import org.jsoup.nodes.Element import java.text.SimpleDateFormat @@ -17,6 +22,7 @@ class ManhwaLatino : Madara( ) { override val client: OkHttpClient = super.client.newBuilder() + .rateLimitHost(baseUrl.toHttpUrl(), 1, 1) .addInterceptor { chain -> val request = chain.request() val headers = request.headers.newBuilder() @@ -43,6 +49,30 @@ class ManhwaLatino : Madara( override val mangaDetailsSelectorDescription = "div.post-content_item:contains(Resumen) div.summary-container" override val pageListParseSelector = "div.page-break img.wp-manga-chapter-img" + private val chapterListNextPageSelector = "div.pagination > span.current + span" + override fun chapterListParse(response: Response): List { + val mangaUrl = response.request.url + var document = response.asJsoup() + launchIO { countViews(document) } + + val chapterList = mutableListOf() + var page = 1 + + do { + val chapterElements = document.select(chapterListSelector()) + if (chapterElements.isEmpty()) break + chapterList.addAll(chapterElements.map { chapterFromElement(it) }) + val hasNextPage = document.select(chapterListNextPageSelector).isNotEmpty() + if (hasNextPage) { + page++ + val nextPageUrl = mangaUrl.newBuilder().setQueryParameter("t", page.toString()).build() + document = client.newCall(GET(nextPageUrl, headers)).execute().asJsoup() + } else { break } + } while (true) + + return chapterList + } + override fun chapterFromElement(element: Element): SChapter { val chapter = SChapter.create()