From 543e8e3267ad7aeaa713d54d17b422012d0d6302 Mon Sep 17 00:00:00 2001 From: hoanphonglinh Date: Fri, 31 Jan 2025 16:06:56 +0000 Subject: [PATCH 1/2] [Manhwaindo] Fix attempt 1 --- .../site/mangareader/id/ManhwaIndoParser.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangareader/id/ManhwaIndoParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangareader/id/ManhwaIndoParser.kt index 79ec50b7..7de3f86a 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangareader/id/ManhwaIndoParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangareader/id/ManhwaIndoParser.kt @@ -4,10 +4,26 @@ import org.koitharu.kotatsu.parsers.MangaLoaderContext import org.koitharu.kotatsu.parsers.MangaSourceParser import org.koitharu.kotatsu.parsers.model.MangaParserSource import org.koitharu.kotatsu.parsers.site.mangareader.MangaReaderParser +import org.koitharu.kotatsu.parsers.model.* +import org.koitharu.kotatsu.parsers.util.* @MangaSourceParser("MANHWAINDO", "ManhwaIndo", "id") internal class ManhwaIndoParser(context: MangaLoaderContext) : MangaReaderParser(context, MangaParserSource.MANHWAINDO, "manhwaindo.one", pageSize = 30, searchPageSize = 10) { override val datePattern = "MMM d, yyyy" override val listUrl = "/series" + + override suspend fun getPages(chapter: MangaChapter): List { + val chapterUrl = chapter.url.toAbsoluteUrl(domain) + val docs = webClient.httpGet(chapterUrl).parseHtml() + return docs.select(selectPage).map { img -> + val url = img.attr("data-src").toRelativeUrl(domain) + MangaPage( + id = generateUid(url), + url = url, + preview = null, + source = source, + ) + } + } } From d86d0a5d5b8f797a583dbdf42f6bac551db04dd5 Mon Sep 17 00:00:00 2001 From: hoanphonglinh Date: Fri, 31 Jan 2025 16:27:41 +0000 Subject: [PATCH 2/2] [Manhwaindo] Fix attempt 2 --- .../site/mangareader/id/ManhwaIndoParser.kt | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangareader/id/ManhwaIndoParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangareader/id/ManhwaIndoParser.kt index 7de3f86a..25203fe1 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangareader/id/ManhwaIndoParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/mangareader/id/ManhwaIndoParser.kt @@ -16,14 +16,23 @@ internal class ManhwaIndoParser(context: MangaLoaderContext) : override suspend fun getPages(chapter: MangaChapter): List { val chapterUrl = chapter.url.toAbsoluteUrl(domain) val docs = webClient.httpGet(chapterUrl).parseHtml() - return docs.select(selectPage).map { img -> - val url = img.attr("data-src").toRelativeUrl(domain) - MangaPage( - id = generateUid(url), - url = url, - preview = null, - source = source, - ) + return docs.select(selectPage).mapNotNull { img -> + val url = img.attr("data-src").takeIf { it.isNotBlank() }?.toRelativeUrl(domain) ?: return@mapNotNull null + try { + val response = webClient.httpHead(url) + if (response.headers["Content-Type"]?.startsWith("image/") == true) { + MangaPage( + id = generateUid(url), + url = url, + preview = null, + source = source, + ) + } else { + null + } + } catch (e: Exception) { + null + } } } }