Fix Jsoup NPE error at Webtoons. (#7342)

This commit is contained in:
Alessandro Jean 2021-05-31 20:03:11 -03:00 committed by GitHub
parent ee2519fd38
commit 69ae60f68a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 8 deletions

View File

@ -158,7 +158,6 @@ open class Webtoons(
} ?: emptyResult
}
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
val url = "$baseUrl/$langCode/search?keyword=$query".toHttpUrlOrNull()?.newBuilder()!!
val uriPart = (filters.find { it is SearchType } as? SearchType)?.toUriPart() ?: ""
@ -186,19 +185,19 @@ open class Webtoons(
val infoElement = document.select("#_asideDetail")
val manga = SManga.create()
manga.title = document.selectFirst("h1.subj").text()
manga.title = document.selectFirst("h1.subj, h3.subj").text()
manga.author = detailElement.select(".author:nth-of-type(1)").first()?.ownText()
manga.artist = detailElement.select(".author:nth-of-type(2)").first()?.ownText() ?: manga.author
manga.genre = detailElement.select(".genre").joinToString(", ") { it.text() }
manga.description = infoElement.select("p.summary").text()
manga.status = infoElement.select("p.day_info").text().orEmpty().let { parseStatus(it) }
manga.status = infoElement.select("p.day_info").firstOrNull()?.text().orEmpty().toStatus()
manga.thumbnail_url = parseDetailsThumbnail(document)
return manga
}
private fun parseStatus(status: String) = when {
status.contains("UP") -> SManga.ONGOING
status.contains("COMPLETED") -> SManga.COMPLETED
private fun String.toStatus(): Int = when {
contains("UP") -> SManga.ONGOING
contains("COMPLETED") -> SManga.COMPLETED
else -> SManga.UNKNOWN
}

View File

@ -13,7 +13,7 @@ class WebtoonsGenerator : ThemeSourceGenerator {
override val baseVersionCode: Int = 1
override val sources = listOf(
MultiLang("Webtoons.com", "https://www.webtoons.com", listOf("en", "fr", "es", "id", "th", "zh"), className = "WebtoonsFactory", pkgName = "webtoons", overrideVersionCode = 28),
MultiLang("Webtoons.com", "https://www.webtoons.com", listOf("en", "fr", "es", "id", "th", "zh"), className = "WebtoonsFactory", pkgName = "webtoons", overrideVersionCode = 29),
SingleLang("Dongman Manhua", "https://www.dongmanmanhua.cn", "zh")
)