MangaFast: ignore unparseable dates (#4371)

* MangaFast: ignore unparseable dates

MangaFast introduced the concept of teaser chapters and just placeholders for upcoming chapters. These do not have a proper date and previously led to a ParseException.

* MangaFast: use more precise chapterListSelector

* MangaFast: bump version
This commit is contained in:
David Ruppelt 2020-09-14 23:32:08 +02:00 committed by GitHub
parent 3037ad7daf
commit 68d53b0225
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'MangaFast'
pkgNameSuffix = 'en.mangafast'
extClass = '.MangaFast'
extVersionCode = 2
extVersionCode = 3
libVersion = '1.2'
}

View File

@ -8,6 +8,7 @@ import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import java.text.ParseException
import java.text.SimpleDateFormat
import java.util.Locale
@ -65,12 +66,20 @@ class MangaFast : ParsedHttpSource() {
else -> SManga.UNKNOWN
}
override fun chapterListSelector() = "tr:has(td.tgs)"
override fun chapterListSelector() = "tr:has(td.tgs:matches(\\d{4}-\\d{2}-\\d{2}))"
override fun chapterFromElement(element: Element) = SChapter.create().apply {
setUrlWithoutDomain(element.select("a").attr("href"))
name = element.select("a").attr("title")
date_upload = dateFormat.parse(element.select("td.tgs").text().trim())?.time ?: 0
date_upload = parseDate(element.select("td.tgs").text())
}
private fun parseDate(text: String): Long {
return try {
dateFormat.parse(text.trim())?.time ?: 0L
} catch (pe: ParseException) { // this can happen for spoiler & release date entries
0L
}
}
companion object {