From 7813eb91170d474ab1ddb59dc5f7355188d25bca Mon Sep 17 00:00:00 2001 From: zhongfly <11155705+zhongfly@users.noreply.github.com> Date: Tue, 24 Dec 2024 20:06:42 +0800 Subject: [PATCH] zaimanhua: fix empty author and upload time (#6786) --- src/zh/zaimanhua/build.gradle | 2 +- .../extension/zh/zaimanhua/ZaimanhuaDto.kt | 24 ++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/zh/zaimanhua/build.gradle b/src/zh/zaimanhua/build.gradle index a34296ae5..552b19fbc 100644 --- a/src/zh/zaimanhua/build.gradle +++ b/src/zh/zaimanhua/build.gradle @@ -1,7 +1,7 @@ ext { extName = 'Zaimanhua' extClass = '.Zaimanhua' - extVersionCode = 3 + extVersionCode = 4 } apply from: "$rootDir/common.gradle" diff --git a/src/zh/zaimanhua/src/eu/kanade/tachiyomi/extension/zh/zaimanhua/ZaimanhuaDto.kt b/src/zh/zaimanhua/src/eu/kanade/tachiyomi/extension/zh/zaimanhua/ZaimanhuaDto.kt index 2dcf6ad2f..5471a8026 100644 --- a/src/zh/zaimanhua/src/eu/kanade/tachiyomi/extension/zh/zaimanhua/ZaimanhuaDto.kt +++ b/src/zh/zaimanhua/src/eu/kanade/tachiyomi/extension/zh/zaimanhua/ZaimanhuaDto.kt @@ -15,14 +15,18 @@ class MangaDto( private val description: String? = null, private val types: List, private val status: List, - private val authors: List, + private val authors: List? = null, @SerialName("chapters") private val chapterGroups: List, + @SerialName("last_update_chapter_id") + private val lastUpdateChapterId: Int = 0, + @SerialName("last_updatetime") + private val lastUpdateTime: Long = 0, ) { fun toSManga() = SManga.create().apply { url = id.toString() title = this@MangaDto.title - author = authors.joinToString { it.name } + author = authors?.joinToString { it.name } description = this@MangaDto.description genre = types.joinToString { it.name } status = parseStatus(this@MangaDto.status[0].name) @@ -32,9 +36,10 @@ class MangaDto( fun parseChapterList(): List { val mangaId = id.toString() + val lastUpdateChapter = lastUpdateChapterId.toString() val size = chapterGroups.sumOf { it.size } return chapterGroups.flatMapTo(ArrayList(size)) { - it.toSChapterList(mangaId) + it.toSChapterList(mangaId, lastUpdateChapter, lastUpdateTime) } } } @@ -44,17 +49,24 @@ class ChapterGroupDto( private val title: String, private val data: List, ) { - fun toSChapterList(mangaId: String): List { + fun toSChapterList(mangaId: String, lastUpdateChapter: String, lastUpdateTime: Long): List { val groupName = title val isDefaultGroup = groupName == "连载" val current = System.currentTimeMillis() return data.map { it.toSChapterInternal().apply { - url = "$mangaId/$url" if (!isDefaultGroup) scanlator = groupName // For some chapters, api will always return current time as upload time // Therefore upload times that differ too little from the current time will be ignored - if ((current - date_upload) < 10000) date_upload = 0 + // When the chapter is the latest chapter, use the last update time as the upload time + if ((current - date_upload) < 10000) { + date_upload = if (url == lastUpdateChapter) { + lastUpdateTime * 1000 + } else { + 0L + } + } + url = "$mangaId/$url" } } }