mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-20 05:29:18 +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)
|
val response = responseToJson(netResponse)
|
||||||
try {
|
try {
|
||||||
val media = response["data"]["SaveMediaListEntry"].asJsonObject
|
val media = response["data"]["SaveMediaListEntry"].asJsonObject
|
||||||
if (track.started_reading_date <= 0L) {
|
val startedDate = parseDate(media, "startedAt")
|
||||||
track.started_reading_date = parseDate(media, "startedAt")
|
if (track.started_reading_date <= 0L || startedDate > 0) {
|
||||||
|
track.started_reading_date = startedDate
|
||||||
}
|
}
|
||||||
if (track.finished_reading_date <= 0L) {
|
val finishedDate = parseDate(media, "completedAt")
|
||||||
track.finished_reading_date = parseDate(media, "completedAt")
|
if (track.finished_reading_date <= 0L || finishedDate > 0) {
|
||||||
|
track.finished_reading_date = finishedDate
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} 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)
|
status = if (isRereading) MyAnimeList.REREADING else getStatus(obj["status"]!!.jsonPrimitive.content)
|
||||||
last_chapter_read = obj["num_chapters_read"]!!.jsonPrimitive.int
|
last_chapter_read = obj["num_chapters_read"]!!.jsonPrimitive.int
|
||||||
score = obj["score"]!!.jsonPrimitive.int.toFloat()
|
score = obj["score"]!!.jsonPrimitive.int.toFloat()
|
||||||
obj["start_date"]?.let {
|
val startedDate = parseDate(obj["start_date"]?.jsonPrimitive?.content ?: "")
|
||||||
started_reading_date = parseDate(it.jsonPrimitive.content)
|
if (track.started_reading_date <= 0L || startedDate > 0) {
|
||||||
|
track.started_reading_date = startedDate
|
||||||
}
|
}
|
||||||
obj["finish_date"]?.let {
|
val finishedDate = parseDate(obj["finish_date"]?.jsonPrimitive?.content ?: "")
|
||||||
finished_reading_date = parseDate(it.jsonPrimitive.content)
|
if (track.finished_reading_date <= 0L || finishedDate > 0) {
|
||||||
|
track.finished_reading_date = finishedDate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseDate(isoDate: String): Long {
|
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? {
|
private fun convertToIsoDate(epochTime: Long): String? {
|
||||||
|
Loading…
Reference in New Issue
Block a user