From b1a4cd44b59cdec1133447e0c81a34b3b7b74ae1 Mon Sep 17 00:00:00 2001 From: Mike <51273546+SnakeDoc83@users.noreply.github.com> Date: Wed, 10 Jun 2020 01:26:22 -0400 Subject: [PATCH] Dmzj - encode imageUrl requests (#3474) --- src/zh/dmzj/build.gradle | 2 +- .../src/eu/kanade/tachiyomi/extension/zh/dmzj/Dmzj.kt | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/zh/dmzj/build.gradle b/src/zh/dmzj/build.gradle index 6a39f7cdc..d7ce2a31e 100644 --- a/src/zh/dmzj/build.gradle +++ b/src/zh/dmzj/build.gradle @@ -5,7 +5,7 @@ ext { appName = 'Tachiyomi: Dmzj' pkgNameSuffix = 'zh.dmzj' extClass = '.Dmzj' - extVersionCode = 8 + extVersionCode = 9 libVersion = '1.2' } diff --git a/src/zh/dmzj/src/eu/kanade/tachiyomi/extension/zh/dmzj/Dmzj.kt b/src/zh/dmzj/src/eu/kanade/tachiyomi/extension/zh/dmzj/Dmzj.kt index 6c8e74b41..775ebd370 100644 --- a/src/zh/dmzj/src/eu/kanade/tachiyomi/extension/zh/dmzj/Dmzj.kt +++ b/src/zh/dmzj/src/eu/kanade/tachiyomi/extension/zh/dmzj/Dmzj.kt @@ -9,6 +9,7 @@ import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.online.HttpSource +import java.net.URLEncoder import java.util.ArrayList import okhttp3.Request import okhttp3.Response @@ -179,6 +180,16 @@ class Dmzj : HttpSource() { return ret } + private fun String.encoded(): String { + return this.chunked(1) + .joinToString("") { if (it in setOf("%", " ", "+", "#")) URLEncoder.encode(it, "UTF-8") else it } + .let { if (it.endsWith(".jp")) "${it}g" else it } + } + + override fun imageRequest(page: Page): Request { + return GET(page.imageUrl!!.encoded(), headers) + } + // Unused, we can get image urls directly from the chapter page override fun imageUrlParse(response: Response) = throw UnsupportedOperationException("This method should not be called!")