webnovel: fix relative date parsing (#4275)

webnovel: adjust date parsing
This commit is contained in:
AwkwardPeak7 2024-07-27 11:14:36 +05:00 committed by Draff
parent 4d291d571d
commit 3e6c9170ab
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
2 changed files with 8 additions and 10 deletions

View File

@ -1,7 +1,7 @@
ext { ext {
extName = 'WebNovel' extName = 'WebNovel'
extClass = '.WebNovel' extClass = '.WebNovel'
extVersionCode = 10 extVersionCode = 11
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -162,15 +162,13 @@ class WebNovel : HttpSource() {
} }
.getOrDefault(emptyMap()) .getOrDefault(emptyMap())
val updateTimes = chapters.map { accurateUpdateTimes[it.id] ?: it.publishTime.toDate() }
// You can pay to get some chapter earlier than others. This privilege is divided into some tiers // You can pay to get some chapter earlier than others. This privilege is divided into some tiers
// We check if user's tier same or more than chapter's. // We check if user's tier same or more than chapter's.
val filteredChapters = chapters.filter { it.userLevel >= it.chapterLevel } val filteredChapters = chapters.filter { it.userLevel >= it.chapterLevel }
// When new privileged chapter is released oldest privileged chapter becomes normal one (in most cases) // When new privileged chapter is released oldest privileged chapter becomes normal one (in most cases)
// but since those normal chapter retain the original upload time we improvise. (This isn't optimal but meh) // but since those normal chapter retain the original upload time we improvise. (This isn't optimal but meh)
return filteredChapters.zip(updateTimes) { chapter, updateTime -> return filteredChapters.map { chapter ->
val namePrefix = when { val namePrefix = when {
chapter.isPremium && !chapter.isAccessibleByUser -> "\uD83D\uDD12 " chapter.isPremium && !chapter.isAccessibleByUser -> "\uD83D\uDD12 "
else -> "" else -> ""
@ -178,7 +176,7 @@ class WebNovel : HttpSource() {
SChapter.create().apply { SChapter.create().apply {
name = namePrefix + chapter.name name = namePrefix + chapter.name
url = "${comic.id}:${chapter.id}" url = "${comic.id}:${chapter.id}"
date_upload = updateTime date_upload = accurateUpdateTimes[comic.id] ?: chapter.publishTime.toDate()
} }
}.toList() }.toList()
} }
@ -193,11 +191,11 @@ class WebNovel : HttpSource() {
val number = DIGIT_REGEX.find(this)?.value?.toIntOrNull() ?: return 0 val number = DIGIT_REGEX.find(this)?.value?.toIntOrNull() ?: return 0
val field = when { val field = when {
contains("yr") -> Calendar.YEAR contains("year") -> Calendar.YEAR
contains("mth") -> Calendar.MONTH contains("month") -> Calendar.MONTH
contains("d") -> Calendar.DAY_OF_MONTH contains("day") -> Calendar.DAY_OF_MONTH
contains("h") -> Calendar.HOUR contains("hour") -> Calendar.HOUR
contains("min") -> Calendar.MINUTE contains("minute") -> Calendar.MINUTE
else -> return 0 else -> return 0
} }