diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/vi/NetTruyen.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/vi/NetTruyen.kt index 173e845b..2ace154a 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/vi/NetTruyen.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/vi/NetTruyen.kt @@ -39,7 +39,7 @@ internal class NetTruyen(context: MangaLoaderContext) : }, tags = mangaTags, rating = doc.selectFirst("div.star input")?.attr("value")?.toFloatOrNull()?.div(5f) ?: RATING_UNKNOWN, - chapters = chaptersDeferred.await().reversed(), + chapters = chaptersDeferred.await(), ) } } diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/vi/NetTruyenFE.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/vi/NetTruyenFE.kt index 782cc4f6..b02fb89b 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/vi/NetTruyenFE.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/vi/NetTruyenFE.kt @@ -1,5 +1,9 @@ package org.koitharu.kotatsu.parsers.site.wpcomics.vi +import kotlinx.coroutines.async +import kotlinx.coroutines.awaitAll +import kotlinx.coroutines.coroutineScope +import org.jsoup.nodes.Element import androidx.collection.ArrayMap import kotlinx.coroutines.sync.withLock import org.koitharu.kotatsu.parsers.MangaLoaderContext @@ -130,4 +134,30 @@ internal class NetTruyenFE(context: MangaLoaderContext) : tagCache = result result } -} + + override suspend fun getPages(chapter: MangaChapter): List { + val fullUrl = chapter.url.toAbsoluteUrl(domain) + val doc = webClient.httpGet(fullUrl).parseHtml() + return coroutineScope { + doc.select(selectPage).map { img -> + async { fetchPage(img) } + }.awaitAll().filterNotNull() + } + } + + private suspend fun fetchPage(img: Element): MangaPage? = runCatchingCancellable { + val url = img.attrAsRelativeUrlOrNull("data-original") ?: return@runCatchingCancellable null + webClient.httpHead(url).use { response -> + if (response.mimeType?.startsWith("image/") == true) { + MangaPage( + id = generateUid(url), + url = url, + preview = null, + source = source, + ) + } else { + null + } + } + }.getOrNull() +} \ No newline at end of file diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/vi/NetTruyenLL.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/vi/NetTruyenLL.kt index fb1e8a0e..f38f3242 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/vi/NetTruyenLL.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/vi/NetTruyenLL.kt @@ -1,5 +1,9 @@ package org.koitharu.kotatsu.parsers.site.wpcomics.vi +import kotlinx.coroutines.async +import kotlinx.coroutines.awaitAll +import kotlinx.coroutines.coroutineScope +import org.jsoup.nodes.Element import androidx.collection.ArrayMap import kotlinx.coroutines.sync.withLock import org.koitharu.kotatsu.parsers.MangaLoaderContext @@ -130,4 +134,30 @@ internal class NetTruyenLL(context: MangaLoaderContext) : tagCache = result result } -} + + override suspend fun getPages(chapter: MangaChapter): List { + val fullUrl = chapter.url.toAbsoluteUrl(domain) + val doc = webClient.httpGet(fullUrl).parseHtml() + return coroutineScope { + doc.select(selectPage).map { img -> + async { fetchPage(img) } + }.awaitAll().filterNotNull() + } + } + + private suspend fun fetchPage(img: Element): MangaPage? = runCatchingCancellable { + val url = img.attrAsRelativeUrlOrNull("data-original") ?: return@runCatchingCancellable null + webClient.httpHead(url).use { response -> + if (response.mimeType?.startsWith("image/") == true) { + MangaPage( + id = generateUid(url), + url = url, + preview = null, + source = source, + ) + } else { + null + } + } + }.getOrNull() +} \ No newline at end of file diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/vi/NetTruyenSSR.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/vi/NetTruyenSSR.kt index 8ceaaaab..bd9588f5 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/vi/NetTruyenSSR.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/vi/NetTruyenSSR.kt @@ -1,5 +1,9 @@ package org.koitharu.kotatsu.parsers.site.wpcomics.vi +import kotlinx.coroutines.async +import kotlinx.coroutines.awaitAll +import kotlinx.coroutines.coroutineScope +import org.jsoup.nodes.Element import androidx.collection.ArrayMap import kotlinx.coroutines.sync.withLock import org.koitharu.kotatsu.parsers.MangaLoaderContext @@ -130,4 +134,30 @@ internal class NetTruyenSSR(context: MangaLoaderContext) : tagCache = result result } -} + + override suspend fun getPages(chapter: MangaChapter): List { + val fullUrl = chapter.url.toAbsoluteUrl(domain) + val doc = webClient.httpGet(fullUrl).parseHtml() + return coroutineScope { + doc.select(selectPage).map { img -> + async { fetchPage(img) } + }.awaitAll().filterNotNull() + } + } + + private suspend fun fetchPage(img: Element): MangaPage? = runCatchingCancellable { + val url = img.attrAsRelativeUrlOrNull("data-original") ?: return@runCatchingCancellable null + webClient.httpHead(url).use { response -> + if (response.mimeType?.startsWith("image/") == true) { + MangaPage( + id = generateUid(url), + url = url, + preview = null, + source = source, + ) + } else { + null + } + } + }.getOrNull() +} \ No newline at end of file diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/vi/NetTruyenUU.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/vi/NetTruyenUU.kt index 61d89101..8e1cc40f 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/vi/NetTruyenUU.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/vi/NetTruyenUU.kt @@ -1,5 +1,9 @@ package org.koitharu.kotatsu.parsers.site.wpcomics.vi +import kotlinx.coroutines.async +import kotlinx.coroutines.awaitAll +import kotlinx.coroutines.coroutineScope +import org.jsoup.nodes.Element import androidx.collection.ArrayMap import kotlinx.coroutines.sync.withLock import org.koitharu.kotatsu.parsers.MangaLoaderContext @@ -130,4 +134,30 @@ internal class NetTruyenUU(context: MangaLoaderContext) : tagCache = result result } -} + + override suspend fun getPages(chapter: MangaChapter): List { + val fullUrl = chapter.url.toAbsoluteUrl(domain) + val doc = webClient.httpGet(fullUrl).parseHtml() + return coroutineScope { + doc.select(selectPage).map { img -> + async { fetchPage(img) } + }.awaitAll().filterNotNull() + } + } + + private suspend fun fetchPage(img: Element): MangaPage? = runCatchingCancellable { + val url = img.attrAsRelativeUrlOrNull("data-original") ?: return@runCatchingCancellable null + webClient.httpHead(url).use { response -> + if (response.mimeType?.startsWith("image/") == true) { + MangaPage( + id = generateUid(url), + url = url, + preview = null, + source = source, + ) + } else { + null + } + } + }.getOrNull() +} \ No newline at end of file diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/vi/NetTruyenVie.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/vi/NetTruyenVie.kt index 3112adda..8f7df42d 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/vi/NetTruyenVie.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/vi/NetTruyenVie.kt @@ -23,7 +23,7 @@ internal class NetTruyenVie(context: MangaLoaderContext) : val tagsElement = doc.select("li.kind p.col-xs-8 a") val mangaTags = tagsElement.mapNotNullToSet { tagMap[it.text()] } manga.copy( - description = doc.selectFirst(selectDesc)?.html(), + description = doc.selectFirst("div.detail-content > div")?.html(), altTitle = doc.selectFirst("h2.other-name")?.textOrNull(), author = doc.body().select(selectAut).textOrNull(), state = doc.selectFirst(selectState)?.let { @@ -35,7 +35,7 @@ internal class NetTruyenVie(context: MangaLoaderContext) : }, tags = mangaTags, rating = doc.selectFirst("div.star input")?.attr("value")?.toFloatOrNull()?.div(5f) ?: RATING_UNKNOWN, - chapters = chaptersDeferred.await().reversed(), + chapters = chaptersDeferred.await(), ) } }