SeriManga: Fix date locale (#2517)
* SeriManga: fix date locale * bump extVersionCode * add try-catch in date parse * add another description selector some mangas use the first selector, example: https://serimangas.com/manga/kara-yonca and some mangas use the second one, example: https://serimangas.com/manga/chainsaw-manrenkli * Fix status selector * Apply suggestions from code review
This commit is contained in:
parent
84fd56dcc1
commit
239a90665d
@ -1,7 +1,7 @@
|
|||||||
ext {
|
ext {
|
||||||
extName = 'SeriManga'
|
extName = 'SeriManga'
|
||||||
extClass = '.SeriManga'
|
extClass = '.SeriManga'
|
||||||
extVersionCode = 4
|
extVersionCode = 5
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
@ -11,6 +11,7 @@ import okhttp3.Request
|
|||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
|
import java.text.ParseException
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
@ -68,16 +69,18 @@ class SeriManga : ParsedHttpSource() {
|
|||||||
override fun searchMangaNextPageSelector() = popularMangaNextPageSelector()
|
override fun searchMangaNextPageSelector() = popularMangaNextPageSelector()
|
||||||
|
|
||||||
override fun mangaDetailsParse(document: Document) = SManga.create().apply {
|
override fun mangaDetailsParse(document: Document) = SManga.create().apply {
|
||||||
description = document.select(".demo1").text()
|
description = document.select(".demo1").text().ifBlank {
|
||||||
|
document.select(".demo1").next().text()
|
||||||
|
}
|
||||||
genre = document.select("div.spc2rcrc-links > a").joinToString { it.text() }
|
genre = document.select("div.spc2rcrc-links > a").joinToString { it.text() }
|
||||||
status = document.select("div.is-status.is-status--green").text().let {
|
status = document.select("div.is-status.is-status--blue").text().let {
|
||||||
parseStatus(it)
|
parseStatus(it)
|
||||||
}
|
}
|
||||||
thumbnail_url = document.select("[rel=image_src]").attr("href")
|
thumbnail_url = document.select("[rel=image_src]").attr("href")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseStatus(status: String) = when {
|
private fun parseStatus(status: String) = when {
|
||||||
status.contains("CONTINUES") -> SManga.ONGOING
|
status.contains("Devam Ediyor") -> SManga.ONGOING
|
||||||
status.contains("Tamamlanmış") -> SManga.COMPLETED
|
status.contains("Tamamlanmış") -> SManga.COMPLETED
|
||||||
else -> SManga.UNKNOWN
|
else -> SManga.UNKNOWN
|
||||||
}
|
}
|
||||||
@ -105,12 +108,16 @@ class SeriManga : ParsedHttpSource() {
|
|||||||
override fun chapterFromElement(element: Element) = SChapter.create().apply {
|
override fun chapterFromElement(element: Element) = SChapter.create().apply {
|
||||||
setUrlWithoutDomain(element.select("a").attr("href"))
|
setUrlWithoutDomain(element.select("a").attr("href"))
|
||||||
name = "${element.select("span").first()!!.text()}: ${element.select("span")[1].text()}"
|
name = "${element.select("span").first()!!.text()}: ${element.select("span")[1].text()}"
|
||||||
date_upload = dateFormat.parse(element.select("span")[2].ownText())?.time ?: 0
|
date_upload = try {
|
||||||
|
dateFormat.parse(element.select("span")[2].ownText())?.time ?: 0
|
||||||
|
} catch (e: ParseException) {
|
||||||
|
0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val dateFormat by lazy {
|
val dateFormat by lazy {
|
||||||
SimpleDateFormat("dd MMMM yyyy", Locale("tr"))
|
SimpleDateFormat("dd MMMM yyyy", Locale("en"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user