Dmzj - encode imageUrl requests (#3474)

This commit is contained in:
Mike 2020-06-10 01:26:22 -04:00 committed by GitHub
parent 6ab30f8e2c
commit b1a4cd44b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: Dmzj'
pkgNameSuffix = 'zh.dmzj'
extClass = '.Dmzj'
extVersionCode = 8
extVersionCode = 9
libVersion = '1.2'
}

View File

@ -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!")