fix(utoon): don't use future upload date (#11713)

This commit is contained in:
David Brochero 2025-11-22 14:28:56 -03:00 committed by Draff
parent 64b3c18350
commit d3e7c52053
Signed by: Draff
GPG Key ID: E8A89F3211677653
2 changed files with 11 additions and 3 deletions

View File

@ -3,7 +3,7 @@ ext {
extClass = '.Utoon'
themePkg = 'madara'
baseUrl = 'https://utoon.net'
overrideVersionCode = 2
overrideVersionCode = 3
isNsfw = false
}

View File

@ -21,9 +21,17 @@ class Utoon : Madara(
override fun chapterFromElement(element: Element): SChapter {
return super.chapterFromElement(element).apply {
// Unfortunately Utoon doesn't include the year in the upload date.
// As a workaround, assume it's from the current year, or last year
// if the date is in the future.
val currentYear = Calendar.getInstance().get(Calendar.YEAR)
date_upload = element.selectFirst("span a")?.attr("title")?.let { parseRelativeDate(it) }
?: parseChapterDate("${element.selectFirst(chapterDateSelector())?.text()} $currentYear")
val upload = element.selectFirst("span a")?.attr("title")?.let { parseRelativeDate(it) } ?: parseChapterDate("${element.selectFirst(chapterDateSelector())?.text()} $currentYear")
val now = System.currentTimeMillis()
date_upload = if (now < upload) {
parseChapterDate("${element.selectFirst(chapterDateSelector())?.text()} ${currentYear - 1}")
} else {
upload
}
}
}
}