Merge pull request #306 from Pavkazzz/rawlh-date

Fix time for Rawlh source
This commit is contained in:
Carlos 2018-04-23 15:17:30 -04:00 committed by GitHub
commit e461fe09dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 3 deletions

View File

@ -5,9 +5,9 @@ ext {
appName = 'Tachiyomi: RawLH'
pkgNameSuffix = "ja.rawlh"
extClass = '.Rawlh'
extVersionCode = 1
extVersionCode = 2
extVersionSuffix = 0
libVersion = '1.0'
libVersion = '1.2'
}
apply from: "$rootDir/common.gradle"

View File

@ -7,6 +7,7 @@ import okhttp3.HttpUrl
import okhttp3.Request
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import java.util.Calendar
class Rawlh : ParsedHttpSource() {
@ -106,14 +107,44 @@ class Rawlh : ParsedHttpSource() {
override fun chapterFromElement(element: Element): SChapter {
val urlElement = element.select("td a").first()
val timeElement = element.select("td time").first()
val chapter = SChapter.create()
chapter.setUrlWithoutDomain("/" + urlElement.attr("href"))
chapter.name = urlElement.text()
chapter.date_upload = 0
chapter.date_upload = parseChapterDate(timeElement.text())
return chapter
}
private fun parseChapterDate(date: String): Long {
val value = date.split(' ')[0].toInt()
return when {
"hour(s) ago" in date -> Calendar.getInstance().apply {
add(Calendar.HOUR_OF_DAY, value * -1)
set(Calendar.SECOND, 0)
set(Calendar.MILLISECOND, 0)
}.timeInMillis
"day(s) ago" in date -> Calendar.getInstance().apply {
add(Calendar.DATE, value * -1)
set(Calendar.SECOND, 0)
set(Calendar.MILLISECOND, 0)
}.timeInMillis
"week(s) ago" in date -> Calendar.getInstance().apply {
add(Calendar.DATE, value * 7 * -1)
set(Calendar.SECOND, 0)
set(Calendar.MILLISECOND, 0)
}.timeInMillis
"month(s) ago" in date -> Calendar.getInstance().apply {
add(Calendar.MONTH, value * -1)
set(Calendar.SECOND, 0)
set(Calendar.MILLISECOND, 0)
}.timeInMillis
else -> {
return 0
}
}
}
override fun pageListParse(document: Document): List<Page> {
val pages = mutableListOf<Page>()