From 42f573c8ce49b629267d7bc273e2f66726f8da40 Mon Sep 17 00:00:00 2001 From: Alessandro Jean Date: Fri, 20 Aug 2021 14:11:05 -0300 Subject: [PATCH] Fix chapters not loading in TS. (#8677) --- src/pt/taosect/build.gradle | 2 +- .../tachiyomi/extension/pt/taosect/TaoSect.kt | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/pt/taosect/build.gradle b/src/pt/taosect/build.gradle index 38640daef..32bd24357 100644 --- a/src/pt/taosect/build.gradle +++ b/src/pt/taosect/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'Tao Sect' pkgNameSuffix = 'pt.taosect' extClass = '.TaoSect' - extVersionCode = 5 + extVersionCode = 6 libVersion = '1.2' } diff --git a/src/pt/taosect/src/eu/kanade/tachiyomi/extension/pt/taosect/TaoSect.kt b/src/pt/taosect/src/eu/kanade/tachiyomi/extension/pt/taosect/TaoSect.kt index 53ac3af97..3f09aa638 100644 --- a/src/pt/taosect/src/eu/kanade/tachiyomi/extension/pt/taosect/TaoSect.kt +++ b/src/pt/taosect/src/eu/kanade/tachiyomi/extension/pt/taosect/TaoSect.kt @@ -133,7 +133,12 @@ class TaoSect : ParsedHttpSource() { name = element.select("td[align='left'] a")!!.text() scanlator = this@TaoSect.name date_upload = element.select("td[align='right']")!!.text().toDate() - setUrlWithoutDomain(element.select("td[align='left'] a")!!.attr("href")) + + // The page have a template problem and it's printing the end of the PHP echo command. + val fixedUrl = element.select("td[align='left'] a")!! + .attr("href") + .substringBeforeLast(";") + setUrlWithoutDomain(fixedUrl) } override fun pageListRequest(chapter: SChapter): Request { @@ -201,11 +206,8 @@ class TaoSect : ParsedHttpSource() { override fun latestUpdatesNextPageSelector() = throw UnsupportedOperationException("Not used") private fun String.toDate(): Long { - return try { - DATE_FORMATTER.parse(this)?.time ?: 0L - } catch (e: ParseException) { - 0L - } + return runCatching { DATE_FORMATTER.parse(this)?.time } + .getOrNull() ?: 0L } private fun String.toStatus() = when (this) { @@ -263,7 +265,7 @@ class TaoSect : ParsedHttpSource() { companion object { private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " + - "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36" + "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36" private val DATE_FORMATTER by lazy { SimpleDateFormat("(dd/MM/yyyy)", Locale.ENGLISH)