mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-20 03:59:16 +01:00
Fix MAL remove date showing old date
This commit is contained in:
parent
72a74ea488
commit
27e6ddd816
@ -87,11 +87,13 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
|
||||
val response = responseToJson(netResponse)
|
||||
try {
|
||||
val media = response["data"]["SaveMediaListEntry"].asJsonObject
|
||||
if (track.started_reading_date <= 0L) {
|
||||
track.started_reading_date = parseDate(media, "startedAt")
|
||||
val startedDate = parseDate(media, "startedAt")
|
||||
if (track.started_reading_date <= 0L || startedDate > 0) {
|
||||
track.started_reading_date = startedDate
|
||||
}
|
||||
if (track.finished_reading_date <= 0L) {
|
||||
track.finished_reading_date = parseDate(media, "completedAt")
|
||||
val finishedDate = parseDate(media, "completedAt")
|
||||
if (track.finished_reading_date <= 0L || finishedDate > 0) {
|
||||
track.finished_reading_date = finishedDate
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
|
@ -208,17 +208,23 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI
|
||||
status = if (isRereading) MyAnimeList.REREADING else getStatus(obj["status"]!!.jsonPrimitive.content)
|
||||
last_chapter_read = obj["num_chapters_read"]!!.jsonPrimitive.int
|
||||
score = obj["score"]!!.jsonPrimitive.int.toFloat()
|
||||
obj["start_date"]?.let {
|
||||
started_reading_date = parseDate(it.jsonPrimitive.content)
|
||||
val startedDate = parseDate(obj["start_date"]?.jsonPrimitive?.content ?: "")
|
||||
if (track.started_reading_date <= 0L || startedDate > 0) {
|
||||
track.started_reading_date = startedDate
|
||||
}
|
||||
obj["finish_date"]?.let {
|
||||
finished_reading_date = parseDate(it.jsonPrimitive.content)
|
||||
val finishedDate = parseDate(obj["finish_date"]?.jsonPrimitive?.content ?: "")
|
||||
if (track.finished_reading_date <= 0L || finishedDate > 0) {
|
||||
track.finished_reading_date = finishedDate
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun parseDate(isoDate: String): Long {
|
||||
return SimpleDateFormat("yyyy-MM-dd", Locale.US).parse(isoDate)?.time ?: 0L
|
||||
return try {
|
||||
SimpleDateFormat("yyyy-MM-dd", Locale.US).parse(isoDate)?.time ?: 0L
|
||||
} catch (_: Exception) {
|
||||
0L
|
||||
}
|
||||
}
|
||||
|
||||
private fun convertToIsoDate(epochTime: Long): String? {
|
||||
|
Loading…
Reference in New Issue
Block a user