From e6a9517a4466149a3341ae2c39f86b954e740f9e Mon Sep 17 00:00:00 2001 From: ObserverOfTime Date: Mon, 1 Nov 2021 13:29:44 +0200 Subject: [PATCH] Tappytoon: unblock page list (#9668) --- src/all/tappytoon/build.gradle | 2 +- .../extension/all/tappytoon/Tappytoon.kt | 27 ++++++++----------- .../extension/all/tappytoon/TappytoonAPI.kt | 2 +- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/all/tappytoon/build.gradle b/src/all/tappytoon/build.gradle index cd00076f3..9134203a5 100644 --- a/src/all/tappytoon/build.gradle +++ b/src/all/tappytoon/build.gradle @@ -6,7 +6,7 @@ ext { extName = 'Tappytoon' pkgNameSuffix = 'all.tappytoon' extClass = '.TappytoonFactory' - extVersionCode = 2 + extVersionCode = 3 isNsfw = true } diff --git a/src/all/tappytoon/src/eu/kanade/tachiyomi/extension/all/tappytoon/Tappytoon.kt b/src/all/tappytoon/src/eu/kanade/tachiyomi/extension/all/tappytoon/Tappytoon.kt index e4c6d7a63..570b26d29 100644 --- a/src/all/tappytoon/src/eu/kanade/tachiyomi/extension/all/tappytoon/Tappytoon.kt +++ b/src/all/tappytoon/src/eu/kanade/tachiyomi/extension/all/tappytoon/Tappytoon.kt @@ -32,20 +32,14 @@ class Tappytoon(override val lang: String) : HttpSource() { override val client = network.client.newBuilder().addInterceptor { chain -> val res = chain.proceed(chain.request()) if (res.isSuccessful) return@addInterceptor res - // Log JSON error if available + // Throw JSON error if available if (res.headers["Content-Type"] == "application/json") { res.body?.string()?.let(json::parseToJsonElement)?.run { - val type = jsonObject["type"]?.jsonPrimitive?.content - val msg = jsonObject["message"]!!.jsonPrimitive.content - Log.e("Tappytoon", "${type ?: "Error"} - $msg") + throw Error(jsonObject["message"]!!.jsonPrimitive.content) } - } else { - res.close() - } - when (val code = res.code) { - 403 -> throw Error("You are not authorized to view this") - else -> throw Error("HTTP error $code") } + res.close() + throw Error("HTTP error ${res.code}") }.build() private val json by injectLazy() @@ -60,7 +54,6 @@ class Tappytoon(override val lang: String) : HttpSource() { val uuid = obj["X-Device-Uuid"]!!.jsonPrimitive.content headers.newBuilder() .set("Origin", "https://www.tappytoon.com") - .set("Referer", "https://www.tappytoon.com/") .set("Accept-Language", lang) .set("Authorization", auth) .set("X-Device-Uuid", uuid) @@ -69,8 +62,9 @@ class Tappytoon(override val lang: String) : HttpSource() { private var nextUrl: String? = null - override fun headersBuilder() = - super.headersBuilder().set("Referer", "https://www.tappytoon.com/") + override fun headersBuilder() = super.headersBuilder() + .set("User-Agent", System.getProperty("http.agent")!!) + .set("Referer", "https://www.tappytoon.com/") override fun latestUpdatesRequest(page: Int) = apiUrl.newBuilder().run { @@ -118,8 +112,9 @@ class Tappytoon(override val lang: String) : HttpSource() { override fun pageListRequest(chapter: SChapter) = apiUrl.newBuilder().run { - addEncodedPathSegments("chapters/${chapter.url}") - addEncodedQueryParameter("includes", "images") + addEncodedPathSegments("content-delivery/contents") + addEncodedQueryParameter("chapterId", chapter.url) + addEncodedQueryParameter("variant", "high") addEncodedQueryParameter("locale", lang) GET(toString(), apiHeaders) } @@ -165,7 +160,7 @@ class Tappytoon(override val lang: String) : HttpSource() { } override fun pageListParse(response: Response) = - response.parse().mapIndexed { idx, img -> + response.parse().mapIndexed { idx, img -> Page(idx, "", img.toString()) } diff --git a/src/all/tappytoon/src/eu/kanade/tachiyomi/extension/all/tappytoon/TappytoonAPI.kt b/src/all/tappytoon/src/eu/kanade/tachiyomi/extension/all/tappytoon/TappytoonAPI.kt index 2540a46eb..dbe6f701d 100644 --- a/src/all/tappytoon/src/eu/kanade/tachiyomi/extension/all/tappytoon/TappytoonAPI.kt +++ b/src/all/tappytoon/src/eu/kanade/tachiyomi/extension/all/tappytoon/TappytoonAPI.kt @@ -56,7 +56,7 @@ class Chapter( } @Serializable -class Images(private val images: List) : List by images +class Media(private val media: List) : List by media @Serializable class URL(private val url: String) {