From cb1d3da58aa62191aa5e504e17c00a3810e9eb3f Mon Sep 17 00:00:00 2001 From: Riztard Lanthorn Date: Thu, 3 Dec 2020 21:43:11 +0700 Subject: [PATCH] Update WP MangaStream (#5002) * clean up mangaDetailsParse * fix KomikRu dateFormat * add timestamp to latest chapter Add timestamp to latest chapter. so source which not provide chapter timestamp will have atleast one. taken from "Updated On" * update ext version --- src/all/wpmangastream/build.gradle | 2 +- .../all/wpmangastream/WPMangaStream.kt | 34 ++++++++++++------- .../all/wpmangastream/WPMangaStreamFactory.kt | 2 +- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/all/wpmangastream/build.gradle b/src/all/wpmangastream/build.gradle index a4ef4caa4..6e90b9bf0 100644 --- a/src/all/wpmangastream/build.gradle +++ b/src/all/wpmangastream/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'WP MangaStream (multiple sources)' pkgNameSuffix = 'all.wpmangastream' extClass = '.WPMangaStreamFactory' - extVersionCode = 35 + extVersionCode = 36 libVersion = '1.2' } diff --git a/src/all/wpmangastream/src/eu/kanade/tachiyomi/extension/all/wpmangastream/WPMangaStream.kt b/src/all/wpmangastream/src/eu/kanade/tachiyomi/extension/all/wpmangastream/WPMangaStream.kt index f911a4704..91a5039c1 100644 --- a/src/all/wpmangastream/src/eu/kanade/tachiyomi/extension/all/wpmangastream/WPMangaStream.kt +++ b/src/all/wpmangastream/src/eu/kanade/tachiyomi/extension/all/wpmangastream/WPMangaStream.kt @@ -13,10 +13,12 @@ import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.online.ParsedHttpSource +import eu.kanade.tachiyomi.util.asJsoup import okhttp3.Headers import okhttp3.HttpUrl import okhttp3.OkHttpClient import okhttp3.Request +import okhttp3.Response import org.json.JSONArray import org.jsoup.nodes.Document import org.jsoup.nodes.Element @@ -163,21 +165,12 @@ abstract class WPMangaStream( override fun mangaDetailsParse(document: Document): SManga { return SManga.create().apply { document.select("div.bigcontent, div.animefull").firstOrNull()?.let { infoElement -> - genre = infoElement.select(".mgen a").joinToString { it.text() } - status = parseStatus(infoElement.select(".imptdt:contains(Status) i").firstOrNull()?.ownText()) - author = infoElement.select(".fmed b:contains(Author)+span").firstOrNull()?.ownText() + genre = infoElement.select("span:contains(Genres:) a, .mgen a").joinToString { it.text() } + status = parseStatus(infoElement.select("span:contains(Status:), .imptdt:contains(Status) i").firstOrNull()?.ownText()) + author = infoElement.select("span:contains(Author:), .fmed b:contains(Author)+span").firstOrNull()?.ownText() artist = infoElement.select(".fmed b:contains(Artist)+span").firstOrNull()?.ownText() - description = infoElement.select("div.entry-content p").joinToString("\n") { it.text() } + description = infoElement.select("div.desc p, div.entry-content p").joinToString("\n") { it.text() } thumbnail_url = infoElement.select("div.thumb img").imgAttr() - - // Some wpmangastream sites still use old wpmangastream manga detail layout - if (author == artist && artist == null) { - genre = infoElement.select("span:contains(Genres:) a").joinToString { it.text() } - status = parseStatus(infoElement.select("span:contains(Status:)").firstOrNull()?.ownText()) - author = infoElement.select("span:contains(Author:)").firstOrNull()?.ownText() - artist = author - description = infoElement.select("div.desc p").joinToString("\n") { it.text() } - } } } } @@ -191,6 +184,21 @@ abstract class WPMangaStream( override fun chapterListSelector() = "div.bxcl ul li, div.cl ul li, li:has(div.chbox):has(div.eph-num)" + override fun chapterListParse(response: Response): List { + val document = response.asJsoup() + val chapters = document.select(chapterListSelector()).map { chapterFromElement(it) } + + // Add timestamp to latest chapter, taken from "Updated On". so source which not provide chapter timestamp will have atleast one + val date = document.select(".fmed:contains(update) time ,span:contains(update) time").attr("datetime") + if (date != "") chapters[0].date_upload = parseDate(date) + + return chapters + } + + private fun parseDate(date: String): Long { + return SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH).parse(date)?.time ?: 0L + } + override fun chapterFromElement(element: Element): SChapter { val urlElement = element.select(".lchx > a, span.leftoff a, div.eph-num > a").first() val chapter = SChapter.create() diff --git a/src/all/wpmangastream/src/eu/kanade/tachiyomi/extension/all/wpmangastream/WPMangaStreamFactory.kt b/src/all/wpmangastream/src/eu/kanade/tachiyomi/extension/all/wpmangastream/WPMangaStreamFactory.kt index 40c1a821f..64be2bde5 100644 --- a/src/all/wpmangastream/src/eu/kanade/tachiyomi/extension/all/wpmangastream/WPMangaStreamFactory.kt +++ b/src/all/wpmangastream/src/eu/kanade/tachiyomi/extension/all/wpmangastream/WPMangaStreamFactory.kt @@ -61,7 +61,7 @@ class WPMangaStreamFactory : SourceFactory { ) } -class KomikRu : WPMangaStream("KomikRu", "https://komikru.com", "id") +class KomikRu : WPMangaStream("KomikRu", "https://komikru.com", "id", SimpleDateFormat("MMMM dd, yyyy", Locale.forLanguageTag("id"))) class MasterKomik : WPMangaStream("MasterKomik", "https://masterkomik.com", "id")