ComicExtra Fix chapter date and URL (#7987)

This commit is contained in:
Myst 2021-07-05 23:01:14 +02:00 committed by GitHub
parent 343f77d2ea
commit 357aeacc29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 21 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'ComicExtra'
pkgNameSuffix = 'en.comicextra'
extClass = '.ComicExtra'
extVersionCode = 8
extVersionCode = 9
libVersion = '1.2'
}

View File

@ -13,13 +13,10 @@ import okhttp3.Request
import okhttp3.Response
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import java.text.ParseException
import java.text.SimpleDateFormat
import java.util.ArrayList
import java.util.Calendar
import java.util.Date
import java.util.Locale
import java.util.regex.Pattern
class ComicExtra : ParsedHttpSource() {
@ -33,8 +30,6 @@ class ComicExtra : ParsedHttpSource() {
override val client: OkHttpClient = network.cloudflareClient
private val datePattern = Pattern.compile("(\\d+) days? ago")
override fun popularMangaSelector() = "div.cartoon-box:has(> div.mb-right)"
override fun latestUpdatesSelector() = "div.hl-box"
@ -139,27 +134,14 @@ class ComicExtra : ParsedHttpSource() {
val dateEl = element.select("td:nth-of-type(2)")
val chapter = SChapter.create()
chapter.setUrlWithoutDomain(urlEl.attr("href"))
chapter.setUrlWithoutDomain(urlEl.attr("href").replace(" ", "%20"))
chapter.name = urlEl.text()
chapter.date_upload = dateEl.text()?.let { dateParse(it) } ?: 0
return chapter
}
private fun dateParse(dateAsString: String): Long {
val date: Date? = try {
SimpleDateFormat("MMM dd, yyyy", Locale.ENGLISH).parse(dateAsString.replace(Regex("(st|nd|rd|th)"), ""))
} catch (e: ParseException) {
val m = datePattern.matcher(dateAsString)
if (dateAsString != "Today" && m.matches()) {
val amount = m.group(1)!!.toInt()
Calendar.getInstance().apply {
add(Calendar.DATE, -amount)
}.time
} else if (dateAsString == "Today") {
Calendar.getInstance().time
} else return 0
}
val date: Date? = SimpleDateFormat("MM/dd/yy", Locale.ENGLISH).parse(dateAsString)
return date?.time ?: 0L
}