From b867e280afc2056da6c1bfe129a73f86abe8a0af Mon Sep 17 00:00:00 2001 From: stevenyomi <95685115+stevenyomi@users.noreply.github.com> Date: Sun, 26 Jun 2022 22:17:01 +0800 Subject: [PATCH] SinMH: reverse chapter list section order for Qinqin (#12331) --- multisrc/overrides/sinmh/qinqin/src/Qinqin.kt | 3 +++ .../kanade/tachiyomi/multisrc/sinmh/SinMH.kt | 18 +++++++++++++----- .../tachiyomi/multisrc/sinmh/SinMHGenerator.kt | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/multisrc/overrides/sinmh/qinqin/src/Qinqin.kt b/multisrc/overrides/sinmh/qinqin/src/Qinqin.kt index 0300da80f..93044f834 100644 --- a/multisrc/overrides/sinmh/qinqin/src/Qinqin.kt +++ b/multisrc/overrides/sinmh/qinqin/src/Qinqin.kt @@ -4,6 +4,7 @@ import android.util.Base64 import eu.kanade.tachiyomi.multisrc.sinmh.SinMH import eu.kanade.tachiyomi.network.GET import org.jsoup.nodes.Document +import org.jsoup.select.Elements import javax.crypto.Cipher import javax.crypto.spec.IvParameterSpec import javax.crypto.spec.SecretKeySpec @@ -14,6 +15,8 @@ class Qinqin : SinMH("亲亲漫画", "https://www.acgqd.com") { override fun mangaDetailsParse(document: Document) = mangaDetailsParseDMZJStyle(document, hasBreadcrumb = true) + override fun Elements.sectionsDescending() = this + // https://www.acgqd.com/js/jmzz20191018.js override fun parsePageImages(chapterImages: String): List { val key = SecretKeySpec("cxNB23W8xzKJV26O".toByteArray(), "AES") diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/sinmh/SinMH.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/sinmh/SinMH.kt index 18838601f..73cb13ee5 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/sinmh/SinMH.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/sinmh/SinMH.kt @@ -15,6 +15,7 @@ import okhttp3.Headers import okhttp3.Response import org.jsoup.nodes.Document import org.jsoup.nodes.Element +import org.jsoup.select.Elements import org.jsoup.select.Evaluator import java.text.SimpleDateFormat import java.util.Locale @@ -29,6 +30,7 @@ abstract class SinMH( _baseUrl: String, override val lang: String = "zh", ) : ParsedHttpSource() { + override val baseUrl = _baseUrl protected open val mobileUrl = _baseUrl.replace("www", "m") override val supportsLatest = true @@ -149,6 +151,7 @@ abstract class SinMH( protected open val dateSelector = ".date" protected open fun List.sortedDescending() = this.asReversed() + protected open fun Elements.sectionsDescending() = this.asReversed() override fun chapterListParse(response: Response): List { return chapterListParse(response, chapterListSelector(), dateSelector) @@ -156,14 +159,19 @@ abstract class SinMH( protected fun chapterListParse(response: Response, listSelector: String, dateSelector: String): List { val document = response.asJsoup() - return document.select(listSelector).map { chapterFromElement(it) }.sortedDescending().apply { - if (isNewDateLogic && this.isNotEmpty()) { - val date = document.selectFirst(dateSelector).textNodes().last().text() - this[0].date_upload = DATE_FORMAT.parse(date)?.time ?: 0L - } + val sectionSelector = listSelector.substringBefore(' ') + val itemSelector = listSelector.substringAfter(' ') + val list = document.select(sectionSelector).sectionsDescending().flatMap { section -> + section.select(itemSelector).map { chapterFromElement(it) }.sortedDescending() } + if (isNewDateLogic && list.isNotEmpty()) { + val date = document.selectFirst(dateSelector).textNodes().last().text() + list[0].date_upload = DATE_FORMAT.parse(date)?.time ?: 0L + } + return list } + /** 必须是 "section item" */ override fun chapterListSelector() = ".chapter-body li > a" override fun chapterFromElement(element: Element) = SChapter.create().apply { runCatching { setUrlWithoutDomain(element.attr("href")) }.onFailure { url = "" } diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/sinmh/SinMHGenerator.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/sinmh/SinMHGenerator.kt index fad6dfc4a..0001b365d 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/sinmh/SinMHGenerator.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/sinmh/SinMHGenerator.kt @@ -22,7 +22,7 @@ class SinMHGenerator : ThemeSourceGenerator { ), SingleLang( name = "Qinqin Manhua", baseUrl = "https://www.acgqd.com", lang = "zh", - className = "Qinqin", sourceName = "亲亲漫画", overrideVersionCode = 0 + className = "Qinqin", sourceName = "亲亲漫画", overrideVersionCode = 1 ), SingleLang( name = "57Manhua", baseUrl = "http://www.wuqimh.net", lang = "zh",