Merge pull request #1432 - dragonx943/sources/wpcomics

[site/wpcomics/vi] Fixes
master
Draken 1 year ago committed by GitHub
commit 92bdefcf9d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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(),
)
}
}

@ -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<MangaPage> {
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()
}

@ -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<MangaPage> {
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()
}

@ -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<MangaPage> {
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()
}

@ -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<MangaPage> {
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()
}

@ -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(),
)
}
}

Loading…
Cancel
Save