From df408c356aa19ba943beb7bfd566c4669befa782 Mon Sep 17 00:00:00 2001 From: Riztard Lanthorn Date: Mon, 14 Dec 2020 19:47:27 +0700 Subject: [PATCH] fix & add latest chapter timestamp (#5129) * fix latest chapter timestamp error when there is no chapter * add latest chapter timestamp to manhuaID --- src/all/wpmangareader/build.gradle | 2 +- .../all/wpmangareader/WPMangaReader.kt | 3 ++- src/id/comicfx/build.gradle | 2 +- .../tachiyomi/extension/id/comicfx/ComicFx.kt | 3 ++- src/id/manhuaid/build.gradle | 2 +- .../extension/id/manhuaid/ManhuaID.kt | 20 +++++++++++++++++++ 6 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/all/wpmangareader/build.gradle b/src/all/wpmangareader/build.gradle index 4336e1695..f084d97aa 100644 --- a/src/all/wpmangareader/build.gradle +++ b/src/all/wpmangareader/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'WP MangaReader (multiple sources)' pkgNameSuffix = 'all.wpmangareader' extClass = '.WPMangaReaderFactory' - extVersionCode = 1 + extVersionCode = 2 libVersion = '1.2' } diff --git a/src/all/wpmangareader/src/eu/kanade/tachiyomi/extension/all/wpmangareader/WPMangaReader.kt b/src/all/wpmangareader/src/eu/kanade/tachiyomi/extension/all/wpmangareader/WPMangaReader.kt index 6b228c334..342c6c12e 100644 --- a/src/all/wpmangareader/src/eu/kanade/tachiyomi/extension/all/wpmangareader/WPMangaReader.kt +++ b/src/all/wpmangareader/src/eu/kanade/tachiyomi/extension/all/wpmangareader/WPMangaReader.kt @@ -93,7 +93,8 @@ abstract class WPMangaReader( // Add timestamp to latest chapter, taken from "Updated On". so source which not provide chapter timestamp will have atleast one val date = document.select(".listinfo li:contains(update) time").attr("datetime") - if (date != "") chapters[0].date_upload = parseDate(date) + val checkChapter = document.select(chapterListSelector()).firstOrNull() + if (date != "" && checkChapter != null) chapters[0].date_upload = parseDate(date) return chapters } diff --git a/src/id/comicfx/build.gradle b/src/id/comicfx/build.gradle index d1763a7fd..49d4df83a 100644 --- a/src/id/comicfx/build.gradle +++ b/src/id/comicfx/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'Comic Fx' pkgNameSuffix = 'id.comicfx' extClass = '.ComicFx' - extVersionCode = 1 + extVersionCode = 2 libVersion = '1.2' } diff --git a/src/id/comicfx/src/eu/kanade/tachiyomi/extension/id/comicfx/ComicFx.kt b/src/id/comicfx/src/eu/kanade/tachiyomi/extension/id/comicfx/ComicFx.kt index 6ac3322a3..ebe75afe5 100644 --- a/src/id/comicfx/src/eu/kanade/tachiyomi/extension/id/comicfx/ComicFx.kt +++ b/src/id/comicfx/src/eu/kanade/tachiyomi/extension/id/comicfx/ComicFx.kt @@ -104,7 +104,8 @@ class ComicFx : ParsedHttpSource() { // Add timestamp to latest chapter, taken from "Updated On". so source which not provide chapter timestamp will have atleast one val updateOn = document.select(".infokomik .infolengkap span:contains(update) b").text() val date = document.select(".infokomik .infolengkap span:contains(update)").text().substringAfter(updateOn) - if (date != "") chapters[0].date_upload = parseDate(date) + val checkChapter = document.select(chapterListSelector()).firstOrNull() + if (date != "" && checkChapter != null) chapters[0].date_upload = parseDate(date) return chapters } diff --git a/src/id/manhuaid/build.gradle b/src/id/manhuaid/build.gradle index 8ab5b806a..2640b90ed 100644 --- a/src/id/manhuaid/build.gradle +++ b/src/id/manhuaid/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'ManhuaID' pkgNameSuffix = 'id.manhuaid' extClass = '.ManhuaID' - extVersionCode = 2 + extVersionCode = 3 libVersion = '1.2' } diff --git a/src/id/manhuaid/src/eu/kanade/tachiyomi/extension/id/manhuaid/ManhuaID.kt b/src/id/manhuaid/src/eu/kanade/tachiyomi/extension/id/manhuaid/ManhuaID.kt index 4097abfa4..8cb059b9a 100644 --- a/src/id/manhuaid/src/eu/kanade/tachiyomi/extension/id/manhuaid/ManhuaID.kt +++ b/src/id/manhuaid/src/eu/kanade/tachiyomi/extension/id/manhuaid/ManhuaID.kt @@ -6,9 +6,13 @@ import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.online.ParsedHttpSource +import eu.kanade.tachiyomi.util.asJsoup import okhttp3.OkHttpClient +import okhttp3.Response import org.jsoup.nodes.Document import org.jsoup.nodes.Element +import java.text.SimpleDateFormat +import java.util.Locale class ManhuaID : ParsedHttpSource() { @@ -71,6 +75,22 @@ class ManhuaID : ParsedHttpSource() { override fun chapterListSelector() = "table.table tr td:first-of-type a" + override fun chapterListParse(response: Response): List { + val document = response.asJsoup() + val chapters = document.select(chapterListSelector()).map { chapterFromElement(it) } + + // Add timestamp to latest chapter, taken from "Updated On". so source which not provide chapter timestamp will have atleast one + val date = document.select("table tr:contains(update) td").text() + val checkChapter = document.select(chapterListSelector()).firstOrNull() + if (date != "" && checkChapter != null) chapters[0].date_upload = parseDate(date) + + return chapters + } + + private fun parseDate(date: String): Long { + return SimpleDateFormat("dd/MM/yyyy", Locale.ENGLISH).parse(date)?.time ?: 0L + } + override fun chapterListRequest(manga: SManga) = GET(baseUrl + manga.url, headers) override fun chapterFromElement(element: Element) = SChapter.create().apply {