use metadata.releaseDate or fileLastModified for chapter date (#4682)

This commit is contained in:
Gauthier 2020-10-22 20:35:43 +08:00 committed by GitHub
parent 8dbc444ec8
commit 89cea3e023
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 2 deletions

View File

@ -1,3 +1,11 @@
## 1.2.18
Minimum Komga version required: `0.63.2`
### Fix
* use metadata.releaseDate or fileLastModified for chapter date
## 1.2.17
Minimum Komga version required: `0.63.2`

View File

@ -5,7 +5,7 @@ ext {
extName = 'Komga'
pkgNameSuffix = 'all.komga'
extClass = '.KomgaFactory'
extVersionCode = 17
extVersionCode = 18
libVersion = '1.2'
}

View File

@ -168,7 +168,8 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
chapter_number = book.metadata.numberSort
name = "${book.metadata.number} - ${book.metadata.title} (${book.size})"
url = "$baseUrl/api/v1/books/${book.id}"
date_upload = parseDate(book.lastModified)
date_upload = book.metadata.releaseDate?.let { parseDate(it) }
?: parseDateTime(book.fileLastModified)
}
}.sortedByDescending { it.chapter_number }
}
@ -219,6 +220,17 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
}
private fun parseDate(date: String?): Long =
if (date == null)
Date().time
else {
try {
SimpleDateFormat("yyyy-MM-dd", Locale.US).parse(date).time
} catch (ex: Exception) {
Date().time
}
}
private fun parseDateTime(date: String?): Long =
if (date == null)
Date().time
else {