mirror of
https://github.com/keiyoushi/extensions-source.git
synced 2024-11-25 11:42:47 +01:00
Comick: filter out delayed chapters (#3161)
filter out delayed chapters
This commit is contained in:
parent
07c9a5cbec
commit
c2a3a40b05
@ -1,7 +1,7 @@
|
||||
ext {
|
||||
extName = 'Comick'
|
||||
extClass = '.ComickFactory'
|
||||
extVersionCode = 44
|
||||
extVersionCode = 45
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
|
@ -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}"
|
||||
}
|
||||
|
@ -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<String> = emptyList(),
|
||||
|
Loading…
Reference in New Issue
Block a user