GocTruyenTranh: Update domain & update parseDate, parseStatus (#11029)

GocTruyenTranh: Update domain & update parseDate, parseStatus, & fix mangaDetailsParse
This commit is contained in:
are-are-are 2025-10-13 20:06:04 +07:00 committed by Draff
parent 9aabbfdd82
commit 5997e5507e
Signed by: Draff
GPG Key ID: E8A89F3211677653
2 changed files with 10 additions and 8 deletions

View File

@ -1,7 +1,7 @@
ext {
extName = 'Goc Truyen Tranh'
extClass = '.GocTruyenTranh'
extVersionCode = 5
extVersionCode = 6
isNsfw = true
}

View File

@ -31,7 +31,7 @@ class GocTruyenTranh : ParsedHttpSource(), ConfigurableSource {
override val lang = "vi"
private val defaultBaseUrl = "https://goctruyentranh.org"
private val defaultBaseUrl = "https://goctruyentranh.net"
override val baseUrl by lazy { getPrefBaseUrl() }
@ -85,7 +85,8 @@ class GocTruyenTranh : ParsedHttpSource(), ConfigurableSource {
private fun parseDate(date: String): Long = runCatching {
val calendar = Calendar.getInstance()
val number = date.replace(Regex("[^0-9]"), "").trim().toInt()
when (date.replace(Regex("[0-9]"), "").trim()) {
when (date.replace(Regex("[0-9]"), "").lowercase().trim()) {
"giây trước" -> calendar.apply { add(Calendar.SECOND, -number) }.timeInMillis
"phút trước" -> calendar.apply { add(Calendar.MINUTE, -number) }.timeInMillis
"giờ trước" -> calendar.apply { add(Calendar.HOUR, -number) }.timeInMillis
"ngày trước" -> calendar.apply { add(Calendar.DAY_OF_YEAR, -number) }.timeInMillis
@ -96,18 +97,19 @@ class GocTruyenTranh : ParsedHttpSource(), ConfigurableSource {
override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException()
override fun mangaDetailsParse(document: Document): SManga = SManga.create().apply {
title = document.selectFirst("section aside:first-child h1")!!.text()
title = document.select("section aside:first-child h1").text()
genre = document.select("span:contains(Thể loại:) ~ a").joinToString { it.text().trim(',', ' ') }
description = document.selectFirst("div.mt-3")?.text()
description = document.select("div.mt-3").joinToString { it.wholeText() }
thumbnail_url = document.selectFirst("section aside:first-child img")?.absUrl("src")
status = parseStatus(document.selectFirst("span:contains(Trạng thái:) + b")?.text())
author = document.select("span:contains(Tác giả:) + b").joinToString { it.text() }
author = document.selectFirst("span:contains(Tác giả:) + b")?.text()
}
private fun parseStatus(status: String?) = when {
status == null -> SManga.UNKNOWN
status.contains("Đang tiến hành", ignoreCase = true) -> SManga.ONGOING
status.contains("Hoàn thành", ignoreCase = true) -> SManga.COMPLETED
listOf("Đang Tiến Hành", "Đang Cập Nhật").any { status.contains(it, ignoreCase = true) } -> SManga.ONGOING
listOf("Hoàn Thành", "Đã Hoàn Thành").any { status.contains(it, ignoreCase = true) } -> SManga.COMPLETED
listOf("Tạm Ngưng", "Tạm Hoãn").any { status.contains(it, ignoreCase = true) } -> SManga.ON_HIATUS
else -> SManga.UNKNOWN
}