WP Comics fix manhuaES manga detail (#5500)

fix manga genre
fix manga description
This commit is contained in:
Riztard Lanthorn 2021-01-21 18:53:59 +07:00 committed by GitHub
parent e9ec0421b2
commit 713cd74637
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 3 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'WP-Comics' extName = 'WP-Comics'
pkgNameSuffix = 'all.wpcomics' pkgNameSuffix = 'all.wpcomics'
extClass = '.WPComicsFactory' extClass = '.WPComicsFactory'
extVersionCode = 20 extVersionCode = 21
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -123,7 +123,7 @@ abstract class WPComics(
} }
} }
private fun String?.toStatus(): Int { open fun String?.toStatus(): Int {
val ongoingWords = listOf("Ongoing", "Updating", "Đang tiến hành") val ongoingWords = listOf("Ongoing", "Updating", "Đang tiến hành")
val completedWords = listOf("Complete", "Hoàn thành") val completedWords = listOf("Complete", "Hoàn thành")
return when { return when {
@ -191,7 +191,7 @@ abstract class WPComics(
// Pages // Pages
// sources sometimes have an image element with an empty attr that isn't really an image // sources sometimes have an image element with an empty attr that isn't really an image
private fun imageOrNull(element: Element): String? { open fun imageOrNull(element: Element): String? {
fun Element.hasValidAttr(attr: String): Boolean { fun Element.hasValidAttr(attr: String): Boolean {
val regex = Regex("""https?://.*""", RegexOption.IGNORE_CASE) val regex = Regex("""https?://.*""", RegexOption.IGNORE_CASE)
return when { return when {

View File

@ -50,6 +50,28 @@ private class ManhuaES : WPComics("Manhua ES", "https://manhuaes.com", "en", Sim
thumbnail_url = element.select("img").firstOrNull()?.attr("abs:src") thumbnail_url = element.select("img").firstOrNull()?.attr("abs:src")
} }
} }
override fun mangaDetailsParse(document: Document): SManga {
return SManga.create().apply {
document.select("article#item-detail").let { info ->
author = info.select("li.author p.col-xs-8").text()
status = info.select("li.status p.col-xs-8").text().toStatus()
genre = info.select(".tags-genre a").joinToString { it.text() }
thumbnail_url = imageOrNull(info.select("div.col-image img").first())
val h3 = info.select(".detail-content h3").text()
val strong = info.select(".detail-content strong").text()
val showMoreFake = info.select(".detail-content .content-readmore").text()
val showMore = info.select(".detail-content .morelink").text()
val rawDesc = info.select("div.detail-content").text()
if (showMoreFake == null || showMoreFake == "") {
description = rawDesc.substringAfter(h3).substringAfter(strong).substringBefore(showMore)
} else {
description = rawDesc.substringAfter(h3).substringAfter(strong).substringBefore(showMoreFake)
}
}
}
}
override val pageListSelector = "div.chapter-detail ul img, div.chapter-detail div:not(.container) > img, div.chapter-detail p > img" override val pageListSelector = "div.chapter-detail ul img, div.chapter-detail div:not(.container) > img, div.chapter-detail p > img"
} }