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' extName = 'TimelessLeaf'
pkgNameSuffix = 'en.timelessleaf' pkgNameSuffix = 'en.timelessleaf'
extClass = '.TimelessLeaf' extClass = '.TimelessLeaf'
extVersionCode = 2 extVersionCode = 3
libVersion = '1.2' libVersion = '1.2'
} }

View File

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