TimelessLeaf add chapter timeStamp (#5078)

* TimelessLeaf add chapter timeStamp

* add spacing
This commit is contained in:
Riztard Lanthorn 2020-12-10 20:39:31 +07:00 committed by GitHub
parent 8b55fd8734
commit 9e9b326c49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'TimelessLeaf'
pkgNameSuffix = 'en.timelessleaf'
extClass = '.TimelessLeaf'
extVersionCode = 2
extVersionCode = 3
libVersion = '1.2'
}

View File

@ -12,6 +12,7 @@ import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.Request
import okhttp3.Response
import rx.Observable
import java.text.SimpleDateFormat
import java.util.Locale
/**
@ -28,6 +29,8 @@ class TimelessLeaf : HttpSource() {
override val supportsLatest: Boolean = false
private val dateFormat: SimpleDateFormat = SimpleDateFormat("yyyy/MM/dd", Locale.US)
// popular manga
override fun popularMangaRequest(page: Int): Request {
@ -100,11 +103,25 @@ class TimelessLeaf : HttpSource() {
return hostedHere.map { el ->
SChapter.create().apply {
setUrlWithoutDomain(el.attr("href"))
// taking timeStamp from url
date_upload = parseChapterDate(el.attr("href").substringAfter("com/").substringAfter("php/"))
name = el.text()
}
}.asReversed()
}
private fun parseChapterDate(date: String): Long {
return try {
dateFormat.parse(date)?.time ?: 0
} catch (_: Exception) {
0L
}
}
private fun parseDate(date: String): Long {
return SimpleDateFormat("yyyy/MM/dd", Locale.ENGLISH).parse(date)?.time ?: 0L
}
// page list
override fun pageListParse(response: Response): List<Page> {