From 68d53b0225dac66ec0fd4ac225d7c1226986376e Mon Sep 17 00:00:00 2001 From: David Ruppelt <44848632+druppelt@users.noreply.github.com> Date: Mon, 14 Sep 2020 23:32:08 +0200 Subject: [PATCH] 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 --- src/en/mangafast/build.gradle | 2 +- .../tachiyomi/extension/en/mangafast/MangaFast.kt | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/en/mangafast/build.gradle b/src/en/mangafast/build.gradle index 35a46b65c..33ee1229e 100644 --- a/src/en/mangafast/build.gradle +++ b/src/en/mangafast/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'MangaFast' pkgNameSuffix = 'en.mangafast' extClass = '.MangaFast' - extVersionCode = 2 + extVersionCode = 3 libVersion = '1.2' } diff --git a/src/en/mangafast/src/eu/kanade/tachiyomi/extension/en/mangafast/MangaFast.kt b/src/en/mangafast/src/eu/kanade/tachiyomi/extension/en/mangafast/MangaFast.kt index 13727b3fe..295a5bcb9 100644 --- a/src/en/mangafast/src/eu/kanade/tachiyomi/extension/en/mangafast/MangaFast.kt +++ b/src/en/mangafast/src/eu/kanade/tachiyomi/extension/en/mangafast/MangaFast.kt @@ -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 {