From 8c4a93d1dc829a6235dc30a050abe93464abf03b Mon Sep 17 00:00:00 2001 From: Draken Date: Mon, 17 Feb 2025 11:57:03 +0000 Subject: [PATCH] [viHentai] Fix attempt 1 --- .../kotatsu/parsers/site/vi/LxManga.kt | 2 +- .../kotatsu/parsers/site/vi/viHentai.kt | 32 +++++++------------ 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vi/LxManga.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vi/LxManga.kt index a1d76a4c..88c6e9fe 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vi/LxManga.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vi/LxManga.kt @@ -209,7 +209,7 @@ internal class LxManga(context: MangaLoaderContext) : PagedMangaParser(context, } private suspend fun availableTags(): Set { - val url = "$domain/the-loai" + val url = "https://$domain/the-loai" val doc = webClient.httpGet(url).parseHtml() return doc.select("nav.grid.grid-cols-3.md\\:grid-cols-8 button").map { button -> diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vi/viHentai.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vi/viHentai.kt index aff01815..1f1b9828 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vi/viHentai.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/vi/viHentai.kt @@ -125,9 +125,8 @@ internal class viHentai(context: MangaLoaderContext) : PagedMangaParser(context, return doc.select("div.grid div.relative").map { div -> val href = div.selectFirst("a[href^=/truyen/]")?.attrOrNull("href") ?: div.parseFailed("Không thể tìm thấy nguồn ảnh của Manga này!") - val coverUrl = div.selectFirstOrThrow("div.cover").let { - it.attrOrNull("data-bg") ?: it.attr("style").cssUrl()?.replace("s3.lxmanga.top", domain) - }.orEmpty() + val coverUrl = div.selectFirst("div.cover")?.attr("style") + ?.substringAfter("url('")?.substringBefore("')") Manga( id = generateUid(href), @@ -137,7 +136,7 @@ internal class viHentai(context: MangaLoaderContext) : PagedMangaParser(context, publicUrl = href.toAbsoluteUrl(domain), rating = RATING_UNKNOWN, isNsfw = true, - coverUrl = coverUrl, + coverUrl = coverUrl.orEmpty(), tags = setOf(), state = null, author = null, @@ -190,22 +189,15 @@ internal class viHentai(context: MangaLoaderContext) : PagedMangaParser(context, override suspend fun getPages(chapter: MangaChapter): List { val fullUrl = chapter.url.toAbsoluteUrl(domain) val doc = webClient.httpGet(fullUrl).parseHtml() - return doc.select("div.text-center div.lazy") - .mapNotNull { div -> - val url = div.attr("data-src") - if (url.endsWith(".jpg", ignoreCase = true) || - url.endsWith(".png", ignoreCase = true) - ) { - MangaPage( - id = generateUid(url), - url = url, - preview = null, - source = source, - ) - } else { - null - } - } + return doc.select("div.text-center img.lazy").mapNotNull { img -> + val url = img.attr("data-src") + MangaPage( + id = generateUid(url), + url = url, + preview = null, + source = source, + ) + } } private fun parseDateTime(dateStr: String): Long = runCatching {