Comick: filter out delayed chapters (#3161)
filter out delayed chapters
This commit is contained in:
parent
608a2c5d2a
commit
d430eb8286
|
@ -1,7 +1,7 @@
|
||||||
ext {
|
ext {
|
||||||
extName = 'Comick'
|
extName = 'Comick'
|
||||||
extClass = '.ComickFactory'
|
extClass = '.ComickFactory'
|
||||||
extVersionCode = 44
|
extVersionCode = 45
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,10 @@ import okhttp3.Response
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
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 java.util.concurrent.TimeUnit
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
|
||||||
|
@ -422,13 +426,31 @@ abstract class Comick(
|
||||||
.substringBefore("/chapters")
|
.substringBefore("/chapters")
|
||||||
.substringAfter(apiUrl)
|
.substringAfter(apiUrl)
|
||||||
|
|
||||||
|
val currentTimestamp = System.currentTimeMillis()
|
||||||
|
|
||||||
return chapterListResponse.chapters
|
return chapterListResponse.chapters
|
||||||
.filter {
|
.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) }
|
.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 {
|
override fun getChapterUrl(chapter: SChapter): String {
|
||||||
return "$baseUrl${chapter.url}"
|
return "$baseUrl${chapter.url}"
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,7 +170,8 @@ class Chapter(
|
||||||
private val hid: String,
|
private val hid: String,
|
||||||
private val lang: String = "",
|
private val lang: String = "",
|
||||||
private val title: 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 chap: String = "",
|
||||||
private val vol: String = "",
|
private val vol: String = "",
|
||||||
@SerialName("group_name") val groups: List<String> = emptyList(),
|
@SerialName("group_name") val groups: List<String> = emptyList(),
|
||||||
|
|
Loading…
Reference in New Issue