Jinman: Fix failed to load image (#3706)
This commit is contained in:
parent
bfbdf30ab9
commit
b6cba48ba7
|
@ -1,7 +1,7 @@
|
||||||
ext {
|
ext {
|
||||||
extName = 'Jinman Tiantang'
|
extName = 'Jinman Tiantang'
|
||||||
extClass = '.Jinmantiantang'
|
extClass = '.Jinmantiantang'
|
||||||
extVersionCode = 42
|
extVersionCode = 43
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import okhttp3.ResponseBody.Companion.toResponseBody
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
|
import java.util.zip.GZIPInputStream
|
||||||
import kotlin.math.floor
|
import kotlin.math.floor
|
||||||
|
|
||||||
object ScrambledImageInterceptor : Interceptor {
|
object ScrambledImageInterceptor : Interceptor {
|
||||||
|
@ -22,13 +23,24 @@ object ScrambledImageInterceptor : Interceptor {
|
||||||
val pathSegments = url.pathSegments
|
val pathSegments = url.pathSegments
|
||||||
val aid = pathSegments[pathSegments.size - 2].toInt()
|
val aid = pathSegments[pathSegments.size - 2].toInt()
|
||||||
if (aid < scrambleId) return response // 对在漫画章节ID为220980之前的图片未进行图片分割,直接放行
|
if (aid < scrambleId) return response // 对在漫画章节ID为220980之前的图片未进行图片分割,直接放行
|
||||||
// 章节ID:220980(包含)之后的漫画(2020.10.27之后)图片进行了分割getRows倒序处理
|
// 章节ID:220980(包含)之后的漫画(2020.10.27之后)图片进行了分割getRows倒序处理
|
||||||
|
val responseBuilder = response.newBuilder()
|
||||||
val imgIndex: String = pathSegments.last().substringBefore('.')
|
val imgIndex: String = pathSegments.last().substringBefore('.')
|
||||||
val res = response.body.byteStream().use {
|
val input = if ("gzip" == response.header("Content-Encoding")) {
|
||||||
decodeImage(it, getRows(aid, imgIndex))
|
responseBuilder.headers(
|
||||||
|
response.headers.newBuilder()
|
||||||
|
.removeAll("Content-Encoding")
|
||||||
|
.removeAll("Content-Length")
|
||||||
|
.build(),
|
||||||
|
)
|
||||||
|
GZIPInputStream(response.body.byteStream())
|
||||||
|
} else {
|
||||||
|
response.body.byteStream()
|
||||||
}
|
}
|
||||||
val outputBytes = res.toResponseBody(jpegMediaType)
|
val newBody = input.use {
|
||||||
return response.newBuilder().body(outputBytes).build()
|
decodeImage(it, getRows(aid, imgIndex))
|
||||||
|
}.toResponseBody(jpegMediaType)
|
||||||
|
return responseBuilder.body(newBody).build()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 220980
|
// 220980
|
||||||
|
|
Loading…
Reference in New Issue