From 713cd746377e91c29f5c90ce589592df1b0937d2 Mon Sep 17 00:00:00 2001 From: Riztard Lanthorn Date: Thu, 21 Jan 2021 18:53:59 +0700 Subject: [PATCH] WP Comics fix manhuaES manga detail (#5500) fix manga genre fix manga description --- src/all/wpcomics/build.gradle | 2 +- .../extension/all/wpcomics/WPComics.kt | 4 ++-- .../extension/all/wpcomics/WPComicsFactory.kt | 22 +++++++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/all/wpcomics/build.gradle b/src/all/wpcomics/build.gradle index efeabf2c3..707442666 100644 --- a/src/all/wpcomics/build.gradle +++ b/src/all/wpcomics/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'WP-Comics' pkgNameSuffix = 'all.wpcomics' extClass = '.WPComicsFactory' - extVersionCode = 20 + extVersionCode = 21 libVersion = '1.2' } diff --git a/src/all/wpcomics/src/eu/kanade/tachiyomi/extension/all/wpcomics/WPComics.kt b/src/all/wpcomics/src/eu/kanade/tachiyomi/extension/all/wpcomics/WPComics.kt index 244b39080..c8941194e 100644 --- a/src/all/wpcomics/src/eu/kanade/tachiyomi/extension/all/wpcomics/WPComics.kt +++ b/src/all/wpcomics/src/eu/kanade/tachiyomi/extension/all/wpcomics/WPComics.kt @@ -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 completedWords = listOf("Complete", "Hoàn thành") return when { @@ -191,7 +191,7 @@ abstract class WPComics( // Pages // 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 { val regex = Regex("""https?://.*""", RegexOption.IGNORE_CASE) return when { diff --git a/src/all/wpcomics/src/eu/kanade/tachiyomi/extension/all/wpcomics/WPComicsFactory.kt b/src/all/wpcomics/src/eu/kanade/tachiyomi/extension/all/wpcomics/WPComicsFactory.kt index 7087995aa..e411bf495 100644 --- a/src/all/wpcomics/src/eu/kanade/tachiyomi/extension/all/wpcomics/WPComicsFactory.kt +++ b/src/all/wpcomics/src/eu/kanade/tachiyomi/extension/all/wpcomics/WPComicsFactory.kt @@ -50,6 +50,28 @@ private class ManhuaES : WPComics("Manhua ES", "https://manhuaes.com", "en", Sim 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" }