Tappytoon: fix image content type (#11086)
This commit is contained in:
parent
28bbcb3612
commit
55fe02563c
|
@ -6,7 +6,7 @@ ext {
|
||||||
extName = 'Tappytoon'
|
extName = 'Tappytoon'
|
||||||
pkgNameSuffix = 'all.tappytoon'
|
pkgNameSuffix = 'all.tappytoon'
|
||||||
extClass = '.TappytoonFactory'
|
extClass = '.TappytoonFactory'
|
||||||
extVersionCode = 5
|
extVersionCode = 6
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,10 @@ import kotlinx.serialization.json.decodeFromJsonElement
|
||||||
import kotlinx.serialization.json.jsonObject
|
import kotlinx.serialization.json.jsonObject
|
||||||
import kotlinx.serialization.json.jsonPrimitive
|
import kotlinx.serialization.json.jsonPrimitive
|
||||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
|
import okhttp3.MediaType.Companion.toMediaType
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
|
import okhttp3.ResponseBody.Companion.toResponseBody
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
|
@ -34,9 +36,11 @@ class Tappytoon(override val lang: String) : HttpSource() {
|
||||||
if (res.isSuccessful) {
|
if (res.isSuccessful) {
|
||||||
if (mime != "application/octet-stream")
|
if (mime != "application/octet-stream")
|
||||||
return@addInterceptor res
|
return@addInterceptor res
|
||||||
// Fix Content-Type header
|
// Fix image content type
|
||||||
return@addInterceptor res.newBuilder()
|
val type = IMG_CONTENT_TYPE.toMediaType()
|
||||||
.header("Content-Type", "image/jpeg").build()
|
val body = res.body!!.bytes().toResponseBody(type)
|
||||||
|
return@addInterceptor res.newBuilder().body(body)
|
||||||
|
.header("Content-Type", IMG_CONTENT_TYPE).build()
|
||||||
}
|
}
|
||||||
// Throw JSON error if available
|
// Throw JSON error if available
|
||||||
if (mime == "application/json") {
|
if (mime == "application/json") {
|
||||||
|
@ -199,6 +203,8 @@ class Tappytoon(override val lang: String) : HttpSource() {
|
||||||
throw UnsupportedOperationException("Not used")
|
throw UnsupportedOperationException("Not used")
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
private const val IMG_CONTENT_TYPE = "image/jpeg"
|
||||||
|
|
||||||
private val apiUrl = "https://api-global.tappytoon.com".toHttpUrl()
|
private val apiUrl = "https://api-global.tappytoon.com".toHttpUrl()
|
||||||
|
|
||||||
private val genres = mapOf(
|
private val genres = mapOf(
|
||||||
|
|
Loading…
Reference in New Issue