From 8b2e4ca2907fe45aaa7f08cd2b4d444e89dfc7e5 Mon Sep 17 00:00:00 2001 From: Mike <51273546+SnakeDoc83@users.noreply.github.com> Date: Wed, 10 Jun 2020 17:09:52 -0400 Subject: [PATCH] Komiku - better covers, fix details (#3483) --- src/id/komiku/build.gradle | 2 +- .../tachiyomi/extension/id/komiku/Komiku.kt | 23 ++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/id/komiku/build.gradle b/src/id/komiku/build.gradle index a960810fa..e3687009c 100644 --- a/src/id/komiku/build.gradle +++ b/src/id/komiku/build.gradle @@ -5,7 +5,7 @@ ext { appName = 'Tachiyomi: Komiku' pkgNameSuffix = 'id.komiku' extClass = '.Komiku' - extVersionCode = 1 + extVersionCode = 2 libVersion = '1.2' } diff --git a/src/id/komiku/src/eu/kanade/tachiyomi/extension/id/komiku/Komiku.kt b/src/id/komiku/src/eu/kanade/tachiyomi/extension/id/komiku/Komiku.kt index 86c6f889f..3a18f5e5a 100644 --- a/src/id/komiku/src/eu/kanade/tachiyomi/extension/id/komiku/Komiku.kt +++ b/src/id/komiku/src/eu/kanade/tachiyomi/extension/id/komiku/Komiku.kt @@ -26,10 +26,19 @@ class Komiku : ParsedHttpSource() { override fun popularMangaRequest(page: Int) = GET("$baseUrl/other/hot/page/$page/?orderby=modified", headers) + private val coverRegex = Regex("""(/Manga-|/Manhua-|/Manhwa-)""") + private val coverUploadRegex = Regex("""/uploads/\d\d\d\d/\d\d/""") + override fun popularMangaFromElement(element: Element) = SManga.create().apply { - setUrlWithoutDomain(element.select("a").attr("href")) + setUrlWithoutDomain(element.select("a:has(h3)").attr("href")) title = element.select("h3").text().trim() - thumbnail_url = element.select("img").attr("src") + + // scraped image doesn't make for a good cover; so try to transform it + // make it null if it contains upload date as those URLs aren't very useful + thumbnail_url = element.select("img").attr("abs:src") + .substringBeforeLast("?") + .replace(coverRegex, "/Komik-") + .let { if (it.contains(coverUploadRegex)) null else it } } override fun popularMangaNextPageSelector() = "a.next.popunder" @@ -53,8 +62,8 @@ class Komiku : ParsedHttpSource() { override fun mangaDetailsParse(document: Document) = SManga.create().apply { description = document.select("#Sinopsis > p").text().trim() genre = document.select("li[itemprop=genre] > a").joinToString { it.text() } - status = parseStatus(document.select("table.inftable > tr > td")[11].text()) - thumbnail_url = document.select("div.ims > img").attr("src") + status = parseStatus(document.select("table.inftable tr > td:contains(Status) + td").text()) + thumbnail_url = document.select("div.ims > img").attr("abs:src") } private fun parseStatus(status: String) = when { @@ -65,13 +74,11 @@ class Komiku : ParsedHttpSource() { override fun chapterListSelector() = "table.chapter tr:has(td.judulseries)" - override fun chapterListRequest(manga: SManga) = GET(baseUrl + manga.url, headers) - override fun chapterFromElement(element: Element) = SChapter.create().apply { setUrlWithoutDomain(element.select("a.popunder").attr("href")) name = element.select("a.popunder").attr("title") - // Has datetime attribute, but all are set to statt of current day for whatever reason, so parsing text instead + // Has datetime attribute, but all are set to start of current day for whatever reason, so parsing text instead date_upload = parseRelativeDate(element.select("time").text().trim()) ?: 0 } @@ -95,7 +102,7 @@ class Komiku : ParsedHttpSource() { override fun pageListParse(document: Document): List { return document.select("div.bc > img").mapIndexed { i, element -> - Page(i, "", element.attr("src")) + Page(i, "", element.attr("abs:src")) } }