Skip to content

Commit

Permalink
SlimeRead: Add SChapter::date_upload (#6918)
Browse files Browse the repository at this point in the history
Add SChapter::date_upload
  • Loading branch information
choppeh authored Jan 3, 2025
1 parent 0ac97a9 commit 7a1853a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib-multisrc/slimereadtheme/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ plugins {
id("lib-multisrc")
}

baseVersionCode = 1
baseVersionCode = 2
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import okhttp3.Request
import okhttp3.Response
import rx.Observable
import uy.kohesive.injekt.injectLazy
import java.text.SimpleDateFormat
import java.util.Locale
import kotlin.math.min

abstract class SlimeReadTheme(
Expand Down Expand Up @@ -186,6 +188,7 @@ abstract class SlimeReadTheme(
return items.map {
SChapter.create().apply {
name = "Cap " + parseChapterNumber(it.number)
date_upload = parseChapterDate(it.updated_at)
chapter_number = it.number
scanlator = it.scan?.scan_name
url = "/book_cap_units?manga_id=$mangaId&cap=${it.number}"
Expand All @@ -201,6 +204,10 @@ abstract class SlimeReadTheme(
.replace(",", ".")
}

private fun parseChapterDate(date: String): Long {
return try { dateFormat.parse(date)!!.time } catch (_: Exception) { 0L }
}

override fun getChapterUrl(chapter: SChapter): String {
val url = "$baseUrl${chapter.url}".toHttpUrl()
val id = url.queryParameter("manga_id")!!
Expand Down Expand Up @@ -242,5 +249,6 @@ abstract class SlimeReadTheme(
companion object {
const val PREFIX_SEARCH = "id:"
val FUNCTION_REGEX = """(?<script>\[""\.concat\("[^,]+,"\."\)\.concat\((?<infix>[^,]+),":\d+"\)\])""".toRegex(RegexOption.DOT_MATCHES_ALL)
val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.ROOT)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ data class MangaInfoDto(
@Serializable
data class ChapterDto(
@SerialName("btc_cap") val number: Float,
@SerialName("btc_date_updated") val updated_at: String,
val scan: ScanDto?,
) {
@Serializable
Expand Down

0 comments on commit 7a1853a

Please sign in to comment.