From 4cc72c2f98feff8f52385851367b77ef67b8f057 Mon Sep 17 00:00:00 2001 From: mobi2002 <48650614+mobi2002@users.noreply.github.com> Date: Wed, 1 Feb 2023 19:47:33 +0500 Subject: [PATCH] Mangahub: fix some chapters not visible (#15207) --- .../tachiyomi/multisrc/mangahub/MangaHub.kt | 24 +++++++++++++++++-- .../multisrc/mangahub/MangaHubGenerator.kt | 2 +- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangahub/MangaHub.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangahub/MangaHub.kt index 25bd13eed..aed3d2df1 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangahub/MangaHub.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangahub/MangaHub.kt @@ -200,16 +200,36 @@ abstract class MangaHub( } // chapters + override fun chapterListParse(response: Response): List { + val document = response.asJsoup() + val head = document.head() + return document.select(chapterListSelector()).map { chapterFromElement(it, head) } + } + override fun chapterListSelector() = ".tab-content ul li" - override fun chapterFromElement(element: Element): SChapter { + private fun chapterFromElement(element: Element, head: Element): SChapter { val chapter = SChapter.create() - chapter.setUrlWithoutDomain(element.select("a[href*='$baseUrl/chapter/']:not([rel=nofollow])").attr("href")) + val potentialLinks = element.select("a[href*='$baseUrl/chapter/']:not([rel=nofollow])") + var visibleLink = "" + potentialLinks.forEach { a -> + val className = a.className() + val styles = head.select("style").html() + if (!styles.contains(".$className { display:none; }")) { + visibleLink = a.attr("href") + return@forEach + } + } + chapter.setUrlWithoutDomain(visibleLink) chapter.name = chapter.url.trimEnd('/').substringAfterLast('/').replace('-', ' ') chapter.date_upload = element.select("small.UovLc").first()?.text()?.let { parseChapterDate(it) } ?: 0 return chapter } + override fun chapterFromElement(element: Element): SChapter { + throw UnsupportedOperationException("Not Used") + } + private fun parseChapterDate(date: String): Long { val now = Calendar.getInstance().apply { set(Calendar.HOUR_OF_DAY, 0) diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangahub/MangaHubGenerator.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangahub/MangaHubGenerator.kt index 9c8904999..b37dde0b6 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangahub/MangaHubGenerator.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangahub/MangaHubGenerator.kt @@ -9,7 +9,7 @@ class MangaHubGenerator : ThemeSourceGenerator { override val themeClass = "MangaHub" - override val baseVersionCode: Int = 15 + override val baseVersionCode: Int = 16 override val sources = listOf( // SingleLang("1Manga.co", "https://1manga.co", "en", isNsfw = true, className = "OneMangaCo"),