Goda (baozimhorg): Update api url (#10299)

* baozimhorg: Update api url

* baozimhorg: fix unparseable date

* baozimhorg: version bump

* baozimhorg: fix some chapter is missing

api v3 return different result depending if there is origin or not

* baozimhorg: cleanup

* baozimhorg: update parseDate function

Co-authored-by: stevenyomi <95685115+stevenyomi@users.noreply.github.com>

* baozimhorg: update parseDate function

* Update headers

Co-authored-by: Vetle Ledaal <vetle.ledaal@gmail.com>

---------

Co-authored-by: stevenyomi <95685115+stevenyomi@users.noreply.github.com>
Co-authored-by: Vetle Ledaal <vetle.ledaal@gmail.com>
This commit is contained in:
Alan Tan 2025-09-01 17:05:33 +08:00 committed by Draff
parent b6bce67308
commit 79bdda34b2
Signed by: Draff
GPG Key ID: E8A89F3211677653
3 changed files with 22 additions and 7 deletions

View File

@ -2,7 +2,7 @@ ext {
extName = 'GoDa'
extClass = '.GoDaManhua'
themePkg = 'goda'
overrideVersionCode = 31
overrideVersionCode = 32
}
apply from: "$rootDir/common.gradle"

View File

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.extension.zh.baozimhorg
import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.model.SChapter
import kotlinx.serialization.Serializable
import java.text.ParsePosition
import java.text.SimpleDateFormat
import java.util.Locale
import java.util.TimeZone
@ -40,13 +41,25 @@ class AttributesDto(
fun toSChapter(mangaSlug: String, mangaId: String, chapterId: String) = SChapter.create().apply {
url = "$mangaSlug/$slug#$mangaId/$chapterId"
name = title
date_upload = dateFormat.parse(updatedAt)!!.time
date_upload = parseDate(updatedAt)
}
}
// Static field, no need for lazy
private val dateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US).apply {
timeZone = TimeZone.getTimeZone("UTC")
private val formats = listOf(
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US).apply {
timeZone = TimeZone.getTimeZone("UTC")
},
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US).apply {
timeZone = TimeZone.getTimeZone("UTC")
},
)
fun parseDate(dateString: String): Long {
for (format in formats) {
val date = format.parse(dateString, ParsePosition(0)) ?: continue
return date.time
}
throw IllegalArgumentException("Unable to parse date: $dateString")
}
@Serializable

View File

@ -23,6 +23,8 @@ class GoDaManhua : GoDa("GoDa漫画", "", "zh"), ConfigurableSource {
override val baseUrl: String
override fun headersBuilder() = super.headersBuilder().add("Referer", "$baseUrl/").add("Origin", baseUrl)
init {
val mirrors = MIRRORS
if (System.getenv("CI") == "true") {
@ -39,13 +41,13 @@ class GoDaManhua : GoDa("GoDa漫画", "", "zh"), ConfigurableSource {
private val json: Json = Injekt.get()
override fun fetchChapterList(mangaId: String): List<SChapter> {
val response = client.newCall(GET("https://api-get-v2.mgsearcher.com/api/manga/get?mid=$mangaId&mode=all", headers)).execute()
val response = client.newCall(GET("https://api-get-v3.mgsearcher.com/api/manga/get?mid=$mangaId&mode=all", headers)).execute()
return json.decodeFromString<ResponseDto<ChapterListDto>>(response.body.string()).data.toChapterList()
}
override fun pageListRequest(mangaId: String, chapterId: String): Request {
if (mangaId.isEmpty() || chapterId.isEmpty()) throw Exception("请刷新漫画")
return GET("https://api-get-v2.mgsearcher.com/api/chapter/getinfo?m=$mangaId&c=$chapterId", headers)
return GET("https://api-get-v3.mgsearcher.com/api/chapter/getinfo?m=$mangaId&c=$chapterId", headers)
}
override fun pageListParse(response: Response): List<Page> {