Merge pull request #306 from Pavkazzz/rawlh-date
Fix time for Rawlh source
This commit is contained in:
commit
e461fe09dd
|
@ -5,9 +5,9 @@ ext {
|
||||||
appName = 'Tachiyomi: RawLH'
|
appName = 'Tachiyomi: RawLH'
|
||||||
pkgNameSuffix = "ja.rawlh"
|
pkgNameSuffix = "ja.rawlh"
|
||||||
extClass = '.Rawlh'
|
extClass = '.Rawlh'
|
||||||
extVersionCode = 1
|
extVersionCode = 2
|
||||||
extVersionSuffix = 0
|
extVersionSuffix = 0
|
||||||
libVersion = '1.0'
|
libVersion = '1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
|
|
@ -7,6 +7,7 @@ import okhttp3.HttpUrl
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
|
import java.util.Calendar
|
||||||
|
|
||||||
class Rawlh : ParsedHttpSource() {
|
class Rawlh : ParsedHttpSource() {
|
||||||
|
|
||||||
|
@ -106,14 +107,44 @@ class Rawlh : ParsedHttpSource() {
|
||||||
|
|
||||||
override fun chapterFromElement(element: Element): SChapter {
|
override fun chapterFromElement(element: Element): SChapter {
|
||||||
val urlElement = element.select("td a").first()
|
val urlElement = element.select("td a").first()
|
||||||
|
val timeElement = element.select("td time").first()
|
||||||
|
|
||||||
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 = 0
|
chapter.date_upload = parseChapterDate(timeElement.text())
|
||||||
return chapter
|
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> {
|
override fun pageListParse(document: Document): List<Page> {
|
||||||
val pages = mutableListOf<Page>()
|
val pages = mutableListOf<Page>()
|
||||||
|
|
Loading…
Reference in New Issue