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 fe00f1dc2..144889368 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