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
This commit is contained in:
Riztard Lanthorn 2020-12-03 21:43:11 +07:00 committed by GitHub
parent 918f2686eb
commit cb1d3da58a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 15 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'WP MangaStream (multiple sources)' extName = 'WP MangaStream (multiple sources)'
pkgNameSuffix = 'all.wpmangastream' pkgNameSuffix = 'all.wpmangastream'
extClass = '.WPMangaStreamFactory' extClass = '.WPMangaStreamFactory'
extVersionCode = 35 extVersionCode = 36
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -13,10 +13,12 @@ import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.ParsedHttpSource import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.Headers import okhttp3.Headers
import okhttp3.HttpUrl import okhttp3.HttpUrl
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
import okhttp3.Response
import org.json.JSONArray import org.json.JSONArray
import org.jsoup.nodes.Document import org.jsoup.nodes.Document
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
@ -163,21 +165,12 @@ abstract class WPMangaStream(
override fun mangaDetailsParse(document: Document): SManga { override fun mangaDetailsParse(document: Document): SManga {
return SManga.create().apply { return SManga.create().apply {
document.select("div.bigcontent, div.animefull").firstOrNull()?.let { infoElement -> document.select("div.bigcontent, div.animefull").firstOrNull()?.let { infoElement ->
genre = infoElement.select(".mgen a").joinToString { it.text() } genre = infoElement.select("span:contains(Genres:) a, .mgen a").joinToString { it.text() }
status = parseStatus(infoElement.select(".imptdt:contains(Status) i").firstOrNull()?.ownText()) status = parseStatus(infoElement.select("span:contains(Status:), .imptdt:contains(Status) i").firstOrNull()?.ownText())
author = infoElement.select(".fmed b:contains(Author)+span").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() 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() 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 chapterListSelector() = "div.bxcl ul li, div.cl ul li, li:has(div.chbox):has(div.eph-num)"
override fun chapterListParse(response: Response): List<SChapter> {
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 { override fun chapterFromElement(element: Element): SChapter {
val urlElement = element.select(".lchx > a, span.leftoff a, div.eph-num > a").first() val urlElement = element.select(".lchx > a, span.leftoff a, div.eph-num > a").first()
val chapter = SChapter.create() val chapter = SChapter.create()

View File

@ -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") class MasterKomik : WPMangaStream("MasterKomik", "https://masterkomik.com", "id")