From 8271cbd637ef50c4eb16d9f29648e3ab564d8520 Mon Sep 17 00:00:00 2001 From: anenasa <84259093+anenasa@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:36:28 +0800 Subject: [PATCH] Happymh: Fix page list and chapter WebView (#6114) --- src/zh/happymh/build.gradle | 2 +- .../tachiyomi/extension/zh/happymh/Happymh.kt | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/zh/happymh/build.gradle b/src/zh/happymh/build.gradle index cfa7d26d6..1d516856d 100644 --- a/src/zh/happymh/build.gradle +++ b/src/zh/happymh/build.gradle @@ -1,7 +1,7 @@ ext { extName = 'Happymh' extClass = '.Happymh' - extVersionCode = 12 + extVersionCode = 13 } apply from: "$rootDir/common.gradle" diff --git a/src/zh/happymh/src/eu/kanade/tachiyomi/extension/zh/happymh/Happymh.kt b/src/zh/happymh/src/eu/kanade/tachiyomi/extension/zh/happymh/Happymh.kt index f0b0caac7..e5a363f53 100644 --- a/src/zh/happymh/src/eu/kanade/tachiyomi/extension/zh/happymh/Happymh.kt +++ b/src/zh/happymh/src/eu/kanade/tachiyomi/extension/zh/happymh/Happymh.kt @@ -151,22 +151,30 @@ class Happymh : HttpSource(), ConfigurableSource { return json.decodeFromString(script).chapterList.map { SChapter.create().apply { val chapterId = it.id - url = "/v2.0/apis/manga/read?code=$comicId&cid=$chapterId&v=v2.13" + url = "/reads/$comicId/$chapterId" name = it.chapterName } } } + override fun getChapterUrl(chapter: SChapter): String { + return baseUrl + chapter.url + } + // Pages override fun pageListRequest(chapter: SChapter): Request { - val url = baseUrl + chapter.url - val comicId = chapter.url.substringAfter("code=").substringBefore("&") - val chapterId = chapter.url.substringAfter("cid=").substringBefore("&") + if (chapter.url.startsWith("/v2.0/apis/manga/read")) { + // Old format is detected + throw Exception("请刷新章节列表") + } + val comicId = chapter.url.substringAfter("/reads/").substringBefore("/") + val chapterId = chapter.url.substringAfterLast("/") + val url = "$baseUrl/v2.0/apis/manga/read?code=$comicId&cid=$chapterId&v=v3.1302723" // Some chapters return 403 without this header val header = headersBuilder() .add("X-Requested-With", "XMLHttpRequest") - .set("Referer", "$baseUrl/reads/$comicId/$chapterId") + .set("Referer", baseUrl + chapter.url) .build() return GET(url, header) }