From 542d58869968f3987ce24ab7e963ef0f576adbff Mon Sep 17 00:00:00 2001 From: anenasa <84259093+anenasa@users.noreply.github.com> Date: Wed, 20 Apr 2022 05:55:08 +0800 Subject: [PATCH] Copymanga: Use api to get page list (#11519) --- src/zh/copymanga/build.gradle | 2 +- .../extension/zh/copymanga/CopyManga.kt | 21 +++++++------------ 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/zh/copymanga/build.gradle b/src/zh/copymanga/build.gradle index 7322148cc..f5230029b 100644 --- a/src/zh/copymanga/build.gradle +++ b/src/zh/copymanga/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'CopyManga' pkgNameSuffix = 'zh.copymanga' extClass = '.CopyManga' - extVersionCode = 24 + extVersionCode = 25 } apply from: "$rootDir/common.gradle" diff --git a/src/zh/copymanga/src/eu/kanade/tachiyomi/extension/zh/copymanga/CopyManga.kt b/src/zh/copymanga/src/eu/kanade/tachiyomi/extension/zh/copymanga/CopyManga.kt index 37544300c..127c70222 100644 --- a/src/zh/copymanga/src/eu/kanade/tachiyomi/extension/zh/copymanga/CopyManga.kt +++ b/src/zh/copymanga/src/eu/kanade/tachiyomi/extension/zh/copymanga/CopyManga.kt @@ -47,6 +47,7 @@ class CopyManga : ConfigurableSource, HttpSource() { private val mainlandCdn2Url = "https://mirror77.mangafuna.xyz" private val overseasCdn1Url = "https://mirror2.mangafunc.fun" private val overseasCdn2Url = "https://mirror.mangafunc.fun" + private val apiUrl = "https://api.copymanga.org" val replaceToMirror2 = Regex("mirror277\\.mangafuna\\.xyz\\:12001") val replaceToMirror = Regex("mirror77\\.mangafuna\\.xyz\\:12001") @@ -226,22 +227,13 @@ class CopyManga : ConfigurableSource, HttpSource() { return retChapter.asReversed() } - override fun pageListRequest(chapter: SChapter) = GET(baseUrl + chapter.url, headers) + override fun pageListRequest(chapter: SChapter) = GET("$apiUrl/api/v3${chapter.url}", headers) override fun pageListParse(response: Response): List { - val document = response.asJsoup() - val disposableData = document.select("div.imageData").first().attr("contentKey") - val disposablePass = this.evaluateScript(document, "jojo") - - val pageJsonString = decryptChapterData(disposableData, disposablePass) - val pageArray = JSONArray(pageJsonString) - + val jsonObject = JSONObject(response.body!!.string()) + val pageArray = jsonObject.getJSONObject("results").getJSONObject("chapter").getJSONArray("contents") val ret = ArrayList(pageArray.length()) for (i in 0 until pageArray.length()) { - var page = pageArray.getJSONObject(i).getString("url") - if (preferences.getBoolean(CHANGE_CDN_OVERSEAS, false)) { - page = replaceToMirror2.replace(page, "mirror2.mangafunc.fun:443") - page = replaceToMirror.replace(page, "mirror.mangafunc.fun:443") - } + val page = pageArray.getJSONObject(i).getString("url") ret.add(Page(i, "", page)) } @@ -251,6 +243,7 @@ class CopyManga : ConfigurableSource, HttpSource() { override fun headersBuilder() = super.headersBuilder() .add("Referer", baseUrl) .add("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36") + .add("region", if (preferences.getBoolean(CHANGE_CDN_OVERSEAS, false)) "0" else "1") // Unused, we can get image urls directly from the chapter page override fun imageUrlParse(response: Response) = @@ -502,7 +495,7 @@ class CopyManga : ConfigurableSource, HttpSource() { val cdnPreference = androidx.preference.CheckBoxPreference(screen.context).apply { key = CHANGE_CDN_OVERSEAS title = "转换图片CDN为境外CDN" - summary = "加载图片使用境外CDN,使用代理的情况下推荐打开此选项(境外CDN可能无法查看一些刚刚更新的漫画,需要等待资源更新到CDN)" + summary = "需要重启软件(及清除章节缓存)以生效。加载图片使用境外CDN,使用代理的情况下推荐打开此选项(境外CDN可能无法查看一些刚刚更新的漫画,需要等待资源更新到CDN)" setOnPreferenceChangeListener { _, newValue -> try {