[wpcomics/vi/nettruyen*] Fix fetch invaild format

master
Draken 1 year ago
parent 319225d645
commit 576de54ef8

@ -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
@ -134,14 +138,26 @@ internal class NetTruyenFE(context: MangaLoaderContext) :
override suspend fun getPages(chapter: MangaChapter): List<MangaPage> {
val fullUrl = chapter.url.toAbsoluteUrl(domain)
val doc = webClient.httpGet(fullUrl).parseHtml()
return doc.select(selectPage).map { url ->
var img = url.attr("data-original").toRelativeUrl(domain)
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(img),
url = img,
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
@ -134,14 +138,26 @@ internal class NetTruyenLL(context: MangaLoaderContext) :
override suspend fun getPages(chapter: MangaChapter): List<MangaPage> {
val fullUrl = chapter.url.toAbsoluteUrl(domain)
val doc = webClient.httpGet(fullUrl).parseHtml()
return doc.select(selectPage).map { url ->
var img = url.attr("data-original").toRelativeUrl(domain)
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(img),
url = img,
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
@ -134,14 +138,26 @@ internal class NetTruyenSSR(context: MangaLoaderContext) :
override suspend fun getPages(chapter: MangaChapter): List<MangaPage> {
val fullUrl = chapter.url.toAbsoluteUrl(domain)
val doc = webClient.httpGet(fullUrl).parseHtml()
return doc.select(selectPage).map { url ->
var img = url.attr("data-original").toRelativeUrl(domain)
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(img),
url = img,
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
@ -134,14 +138,26 @@ internal class NetTruyenUU(context: MangaLoaderContext) :
override suspend fun getPages(chapter: MangaChapter): List<MangaPage> {
val fullUrl = chapter.url.toAbsoluteUrl(domain)
val doc = webClient.httpGet(fullUrl).parseHtml()
return doc.select(selectPage).map { url ->
var img = url.attr("data-original").toRelativeUrl(domain)
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(img),
url = img,
id = generateUid(url),
url = url,
preview = null,
source = source,
)
} else {
null
}
}
}.getOrNull()
}
Loading…
Cancel
Save