优化
This commit is contained in:
@@ -46,7 +46,7 @@ class OkHttpStreamFetcher(
|
|||||||
private var call: Call? = null
|
private var call: Call? = null
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val failUrl = hashSetOf<String>()
|
private val failUrl = hashSetOf<String>()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadData(priority: Priority, callback: DataFetcher.DataCallback<in InputStream>) {
|
override fun loadData(priority: Priority, callback: DataFetcher.DataCallback<in InputStream>) {
|
||||||
@@ -114,7 +114,9 @@ class OkHttpStreamFetcher(
|
|||||||
responseBody = response.body
|
responseBody = response.body
|
||||||
if (response.isSuccessful) {
|
if (response.isSuccessful) {
|
||||||
val decodeResult = runScriptWithContext(coroutineContext) {
|
val decodeResult = runScriptWithContext(coroutineContext) {
|
||||||
if (manga) {
|
if (ImageUtils.skipDecode(source, !manga)) {
|
||||||
|
responseBody!!.byteStream()
|
||||||
|
} else if (manga) {
|
||||||
ImageUtils.decode(
|
ImageUtils.decode(
|
||||||
oldUrl.toString(),
|
oldUrl.toString(),
|
||||||
responseBody!!.bytes(),
|
responseBody!!.bytes(),
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package io.legado.app.utils
|
package io.legado.app.utils
|
||||||
|
|
||||||
import io.legado.app.constant.AppLog
|
import io.legado.app.constant.AppLog
|
||||||
import io.legado.app.data.entities.Book
|
|
||||||
import io.legado.app.data.entities.BaseSource
|
import io.legado.app.data.entities.BaseSource
|
||||||
|
import io.legado.app.data.entities.Book
|
||||||
import io.legado.app.data.entities.BookSource
|
import io.legado.app.data.entities.BookSource
|
||||||
import io.legado.app.data.entities.RssSource
|
import io.legado.app.data.entities.RssSource
|
||||||
import java.io.InputStream
|
|
||||||
import java.io.ByteArrayInputStream
|
import java.io.ByteArrayInputStream
|
||||||
|
import java.io.InputStream
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加密图片解密工具
|
* 加密图片解密工具
|
||||||
@@ -54,13 +54,18 @@ object ImageUtils {
|
|||||||
}.getOrNull()
|
}.getOrNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun skipDecode(source: BaseSource?, isCover: Boolean): Boolean {
|
||||||
|
return getRuleJs(source, isCover).isNullOrBlank()
|
||||||
|
}
|
||||||
|
|
||||||
private fun getRuleJs(
|
private fun getRuleJs(
|
||||||
source: BaseSource?, isCover: Boolean
|
source: BaseSource?, isCover: Boolean
|
||||||
): String? {
|
): String? {
|
||||||
return when (source) {
|
return when (source) {
|
||||||
is BookSource ->
|
is BookSource ->
|
||||||
if (isCover) source.coverDecodeJs else source.getContentRule().imageDecode
|
if (isCover) source.coverDecodeJs
|
||||||
|
else source.getContentRule().imageDecode
|
||||||
|
|
||||||
is RssSource -> source.coverDecodeJs
|
is RssSource -> source.coverDecodeJs
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user