Fix empty chapter names in Kemono (#14903)

* Fix empty chapter names in Kemono.

* Remove double Date creation.
This commit is contained in:
Alessandro Jean 2023-01-11 16:59:39 -03:00 committed by GitHub
parent ecdaaf98d0
commit 5dc59917af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 3 deletions

View File

@ -67,14 +67,24 @@ class KemonoPostDto(
}.distinctBy { it.path }.map { it.toString() }
fun toSChapter() = SChapter.create().apply {
val postDate = dateFormat.parse(edited ?: published ?: added)
url = "/$service/user/$user/post/$id"
name = title
date_upload = dateFormat.parse(edited ?: published ?: added)?.time ?: 0
date_upload = postDate?.time ?: 0
name = title.ifBlank {
val postDateString = when {
postDate != null && postDate.time != 0L -> chapterNameDateFormat.format(postDate)
else -> "unknown date"
}
"Post from $postDateString"
}
chapter_number = -2f
}
companion object {
val dateFormat by lazy { getApiDateFormat() }
val chapterNameDateFormat by lazy { getChapterNameDateFormat() }
}
}
@ -88,3 +98,6 @@ class KemonoAttachmentDto(val name: String, val path: String) {
private fun getApiDateFormat() =
SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.ENGLISH)
private fun getChapterNameDateFormat() =
SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss", Locale.ENGLISH)

View File

@ -4,9 +4,13 @@ import generator.ThemeSourceData.SingleLang
import generator.ThemeSourceGenerator
class KemonoGenerator : ThemeSourceGenerator {
override val themeClass = "Kemono"
override val themePkg = "kemono"
override val baseVersionCode = 4
override val baseVersionCode = 5
override val sources = listOf(
SingleLang("Kemono", "https://kemono.party", "all", isNsfw = true),
SingleLang("Coomer", "https://coomer.party", "all", isNsfw = true)