From d430eb8286a837da0256b23625487768dc213a9b Mon Sep 17 00:00:00 2001 From: AwkwardPeak7 <48650614+AwkwardPeak7@users.noreply.github.com> Date: Wed, 22 May 2024 10:33:37 +0500 Subject: [PATCH] Comick: filter out delayed chapters (#3161) filter out delayed chapters --- src/all/comickfun/build.gradle | 2 +- .../extension/all/comickfun/Comick.kt | 24 ++++++++++++++++++- .../tachiyomi/extension/all/comickfun/Dto.kt | 3 ++- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/all/comickfun/build.gradle b/src/all/comickfun/build.gradle index 72f9c69bb..0ec80ab12 100644 --- a/src/all/comickfun/build.gradle +++ b/src/all/comickfun/build.gradle @@ -1,7 +1,7 @@ ext { extName = 'Comick' extClass = '.ComickFactory' - extVersionCode = 44 + extVersionCode = 45 isNsfw = true } diff --git a/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/Comick.kt b/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/Comick.kt index 0d9e2702f..0cd83fc18 100644 --- a/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/Comick.kt +++ b/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/Comick.kt @@ -27,6 +27,10 @@ import okhttp3.Response import rx.Observable import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get +import java.text.ParseException +import java.text.SimpleDateFormat +import java.util.Locale +import java.util.TimeZone import java.util.concurrent.TimeUnit import kotlin.math.min @@ -422,13 +426,31 @@ abstract class Comick( .substringBefore("/chapters") .substringAfter(apiUrl) + val currentTimestamp = System.currentTimeMillis() + return chapterListResponse.chapters .filter { - it.groups.map { g -> g.lowercase() }.intersect(preferences.ignoredGroups).isEmpty() + val publishTime = try { + publishedDateFormat.parse(it.publishedAt)!!.time + } catch (_: ParseException) { + 0L + } + + val publishedChapter = publishTime <= currentTimestamp + + val noGroupBlock = it.groups.map { g -> g.lowercase() } + .intersect(preferences.ignoredGroups) + .isEmpty() + + publishedChapter && noGroupBlock } .map { it.toSChapter(mangaUrl) } } + private val publishedDateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ENGLISH).apply { + timeZone = TimeZone.getTimeZone("UTC") + } + override fun getChapterUrl(chapter: SChapter): String { return "$baseUrl${chapter.url}" } diff --git a/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/Dto.kt b/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/Dto.kt index f4359c751..a8058baf5 100644 --- a/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/Dto.kt +++ b/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/Dto.kt @@ -170,7 +170,8 @@ class Chapter( private val hid: String, private val lang: String = "", private val title: String = "", - @SerialName("created_at") val createdAt: String = "", + @SerialName("created_at") private val createdAt: String = "", + @SerialName("publish_at") val publishedAt: String = "", private val chap: String = "", private val vol: String = "", @SerialName("group_name") val groups: List = emptyList(),