From 66cd27a6736736023f4cf31124f36cb76f27bee9 Mon Sep 17 00:00:00 2001 From: Naga <94557604+NagaYZ@users.noreply.github.com> Date: Sun, 3 Aug 2025 19:55:51 +0200 Subject: [PATCH] [Manhastro] Fix chapter list (#2040) Close #1376 #1362 --- .../parsers/site/madara/pt/Manhastro.kt | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/pt/Manhastro.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/pt/Manhastro.kt index fe00f1dc..14488936 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/pt/Manhastro.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/madara/pt/Manhastro.kt @@ -1,15 +1,19 @@ package org.koitharu.kotatsu.parsers.site.madara.pt +import org.jsoup.nodes.Document import org.koitharu.kotatsu.parsers.MangaLoaderContext import org.koitharu.kotatsu.parsers.MangaSourceParser +import org.koitharu.kotatsu.parsers.model.Manga import org.koitharu.kotatsu.parsers.model.MangaChapter import org.koitharu.kotatsu.parsers.model.MangaPage import org.koitharu.kotatsu.parsers.model.MangaParserSource import org.koitharu.kotatsu.parsers.site.madara.MadaraParser import org.koitharu.kotatsu.parsers.util.generateUid +import org.koitharu.kotatsu.parsers.util.mapChapters import org.koitharu.kotatsu.parsers.util.parseHtml import org.koitharu.kotatsu.parsers.util.selectFirstOrThrow import org.koitharu.kotatsu.parsers.util.toAbsoluteUrl +import org.koitharu.kotatsu.parsers.util.toRelativeUrl @MangaSourceParser("MANHASTRO", "Manhastro", "pt") internal class Manhastro(context: MangaLoaderContext) : @@ -35,4 +39,42 @@ internal class Manhastro(context: MangaLoaderContext) : ) } } + + override suspend fun getChapters(manga: Manga, doc: Document): List { + val initialChapters = super.getChapters(manga, doc) + + if (initialChapters.isEmpty()) { + return initialChapters + } + + // Use the URL of the first (latest) chapter to fetch the chapter page. + val firstChapterUrl = initialChapters.first().url.toAbsoluteUrl(domain) + val chapterPageDoc = webClient.httpGet(firstChapterUrl).parseHtml() + + // Select all