From febc0ba112c257f87755a8519ed6fb5cca5b8cc7 Mon Sep 17 00:00:00 2001 From: sinkableShip <89952969+sinkableShip@users.noreply.github.com> Date: Wed, 22 May 2024 12:23:44 +0700 Subject: [PATCH] DMC Scans: Fix selectors (#2529) * fix manga description selector * fix chapter feed selector * fix selector to script that contain pages link * bump overrideVersionCode * bump baseVersionCode * Revert "bump baseVersionCode" This reverts commit 7b2cc6a937193130e7ce9532597dc4d23547985e. * change rate limit * change few selectors that affected because recent changes * change some selectors and other things * change calling super.pageListParse(response) into just copying the code calling super.pageListParse(response) will cause java.lang.IllegalStateException: closed since response.asJsoup() will be called twice * fix indentation * add excluded category: web novel --- .../multisrc/zeistmanga/ZeistManga.kt | 6 ++-- src/en/dmcscans/build.gradle | 2 +- .../extension/en/dmcscans/DMCScans.kt | 36 ++++++++++++++++--- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/lib-multisrc/zeistmanga/src/eu/kanade/tachiyomi/multisrc/zeistmanga/ZeistManga.kt b/lib-multisrc/zeistmanga/src/eu/kanade/tachiyomi/multisrc/zeistmanga/ZeistManga.kt index 49e69121a..87f23619c 100644 --- a/lib-multisrc/zeistmanga/src/eu/kanade/tachiyomi/multisrc/zeistmanga/ZeistManga.kt +++ b/lib-multisrc/zeistmanga/src/eu/kanade/tachiyomi/multisrc/zeistmanga/ZeistManga.kt @@ -212,8 +212,8 @@ abstract class ZeistManga( protected open val useNewChapterFeed = false protected open val useOldChapterFeed = false - private val chapterFeedRegex = """clwd\.run\(["'](.*?)["']\)""".toRegex() - private val scriptSelector = "#clwd > script" + protected open val chapterFeedRegex = """clwd\.run\(["'](.*?)["']\)""".toRegex() + protected open val scriptSelector = "#clwd > script" open fun getChapterFeedUrl(doc: Document): String { if (useNewChapterFeed) return newChapterFeedUrl(doc) @@ -434,6 +434,6 @@ abstract class ZeistManga( companion object { private const val maxMangaResults = 20 - private const val maxChapterResults = 999999 + const val maxChapterResults = 999999 } } diff --git a/src/en/dmcscans/build.gradle b/src/en/dmcscans/build.gradle index ada18b6bb..8f2316490 100644 --- a/src/en/dmcscans/build.gradle +++ b/src/en/dmcscans/build.gradle @@ -3,7 +3,7 @@ ext { extClass = '.DMCScans' themePkg = 'zeistmanga' baseUrl = 'https://didascans.blogspot.com' - overrideVersionCode = 0 + overrideVersionCode = 1 } apply from: "$rootDir/common.gradle" diff --git a/src/en/dmcscans/src/eu/kanade/tachiyomi/extension/en/dmcscans/DMCScans.kt b/src/en/dmcscans/src/eu/kanade/tachiyomi/extension/en/dmcscans/DMCScans.kt index 0a6a6f078..2575c95ad 100644 --- a/src/en/dmcscans/src/eu/kanade/tachiyomi/extension/en/dmcscans/DMCScans.kt +++ b/src/en/dmcscans/src/eu/kanade/tachiyomi/extension/en/dmcscans/DMCScans.kt @@ -7,10 +7,12 @@ import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.util.asJsoup import okhttp3.Response import org.jsoup.Jsoup +import org.jsoup.nodes.Document +import java.util.concurrent.TimeUnit class DMCScans : ZeistManga("DMC Scans", "https://didascans.blogspot.com", "en") { override val client = super.client.newBuilder() - .rateLimit(2) + .rateLimit(1, 3, TimeUnit.SECONDS) .build() // ============================== Popular =============================== @@ -19,10 +21,32 @@ class DMCScans : ZeistManga("DMC Scans", "https://didascans.blogspot.com", "en") override val popularMangaSelectorTitle = ".post-title a" override val popularMangaSelectorUrl = ".post-title a" + // ============================== Search ================================ + + override val excludedCategories = listOf("Web Novel") + // =========================== Manga Details ============================ override val mangaDetailsSelectorGenres = "#labels > a[rel=tag]" - override val mangaDetailsSelectorInfo = ".imptdt" + override val mangaDetailsSelectorInfo = ".imptdts" + override val mangaDetailsSelectorDescription = "p" + override val mangaDetailsSelectorInfoDescription = "div:containsOwn(Status) > span" + + // =========================== Chapter Feed ============================= + + override val chapterFeedRegex = """.run\(["'](.*?)["']\)""".toRegex() + + override fun getChapterFeedUrl(doc: Document): String { + val feed = chapterFeedRegex + .find(doc.html()) + ?.groupValues?.get(1) + ?: throw Exception("Failed to find chapter feed") + + return apiUrl(chapterCategory) + .addPathSegments(feed) + .addQueryParameter("max-results", maxChapterResults.toString()) + .build().toString() + } // =============================== Filters ============================== @@ -47,9 +71,9 @@ class DMCScans : ZeistManga("DMC Scans", "https://didascans.blogspot.com", "en") override fun pageListParse(response: Response): List { val document = response.asJsoup() - val imgData = document.selectFirst("script:containsData(imgTags)") + val imgData = document.selectFirst("script:containsData(imgTag)") ?.data() - ?.substringAfter("imgTags") + ?.substringAfter("imgTag") ?.substringAfter("`") ?.substringBefore("`") ?.replace("\\\"", "\"") @@ -57,7 +81,9 @@ class DMCScans : ZeistManga("DMC Scans", "https://didascans.blogspot.com", "en") ?.replace("\\/", "/") ?.replace("\\:", ":") ?.let(Jsoup::parseBodyFragment) - ?: return super.pageListParse(response) + ?: return document.select(pageListSelector).select("img[src]").mapIndexed { i, img -> + Page(i, "", img.attr("abs:src")) + } return imgData.select("img[src]").mapIndexed { i, img -> Page(i, imageUrl = img.attr("abs:src"))