Toonily: Fix chapter date parsing (#1533)
Toonily: Update chapter date parsing
This commit is contained in:
parent
ccb12ca509
commit
2b8629b21a
@ -5,7 +5,7 @@ ext {
|
|||||||
appName = 'Tachiyomi: Toonily'
|
appName = 'Tachiyomi: Toonily'
|
||||||
pkgNameSuffix = 'en.toonily'
|
pkgNameSuffix = 'en.toonily'
|
||||||
extClass = '.Toonily'
|
extClass = '.Toonily'
|
||||||
extVersionCode = 2
|
extVersionCode = 3
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,17 +144,41 @@ class Toonily: ParsedHttpSource() {
|
|||||||
val chapter = SChapter.create()
|
val chapter = SChapter.create()
|
||||||
chapter.setUrlWithoutDomain(urlElement.attr("href"))
|
chapter.setUrlWithoutDomain(urlElement.attr("href"))
|
||||||
chapter.name = urlElement.text()
|
chapter.name = urlElement.text()
|
||||||
chapter.date_upload = element.select("span.chapter-release-date i").last()?.text()?.let {
|
val new = element.select(".c-new-tag img").attr("alt")
|
||||||
try {
|
if (new.isNotEmpty())
|
||||||
SimpleDateFormat("MMMM dd, yyyy", Locale.US).parse(it).time
|
chapter.date_upload = parseChapterDate(new)
|
||||||
} catch (e: ParseException) {
|
else {
|
||||||
SimpleDateFormat("MMM dd, yyyy", Locale.US).parse(it).time
|
chapter.date_upload = element.select("span.chapter-release-date i").last()?.text()?.let {
|
||||||
}
|
try {
|
||||||
|
SimpleDateFormat("MMMM dd, yyyy", Locale.US).parse(it).time
|
||||||
} ?: 0
|
} catch (e: ParseException) {
|
||||||
|
SimpleDateFormat("MMM dd, yyyy", Locale.US).parse(it).time
|
||||||
|
}
|
||||||
|
} ?: 0
|
||||||
|
}
|
||||||
return chapter
|
return chapter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun parseChapterDate(date: String): Long {
|
||||||
|
val value = date.split(' ')[0].toInt()
|
||||||
|
|
||||||
|
return when {
|
||||||
|
"mins" in date -> Calendar.getInstance().apply {
|
||||||
|
add(Calendar.MINUTE, value * -1)
|
||||||
|
}.timeInMillis
|
||||||
|
"hours" in date -> Calendar.getInstance().apply {
|
||||||
|
add(Calendar.HOUR_OF_DAY, value * -1)
|
||||||
|
}.timeInMillis
|
||||||
|
"days" in date -> Calendar.getInstance().apply {
|
||||||
|
add(Calendar.DATE, value * -1)
|
||||||
|
}.timeInMillis
|
||||||
|
else -> {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun prepareNewChapter(chapter: SChapter, manga: SManga) {
|
override fun prepareNewChapter(chapter: SChapter, manga: SManga) {
|
||||||
val basic = Regex("""Chapter\s([0-9]+)""")
|
val basic = Regex("""Chapter\s([0-9]+)""")
|
||||||
when {
|
when {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user