|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
package io.legado.app.model.analyzeRule |
|
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint |
|
|
|
|
import android.util.Base64 |
|
|
|
|
import androidx.annotation.Keep |
|
|
|
|
import com.bumptech.glide.load.model.GlideUrl |
|
|
|
|
import com.bumptech.glide.load.model.LazyHeaders |
|
|
|
@ -461,9 +462,17 @@ class AnalyzeUrl( |
|
|
|
|
* 访问网站,返回ByteArray |
|
|
|
|
*/ |
|
|
|
|
suspend fun getByteArrayAwait(): ByteArray { |
|
|
|
|
val dataUriRegex = Regex("data:[\\w/\\-\\.]+;base64,(.*)") |
|
|
|
|
val dataUriFindResult = dataUriRegex.find(urlNoQuery) |
|
|
|
|
val concurrentRecord = fetchStart() |
|
|
|
|
setCookie(source?.getKey()) |
|
|
|
|
@Suppress("BlockingMethodInNonBlockingContext") |
|
|
|
|
if (dataUriFindResult != null){ |
|
|
|
|
val dataUriBase64 = dataUriFindResult.groupValues?.get(1) |
|
|
|
|
val byteArray = Base64.decode(dataUriBase64, Base64.DEFAULT) |
|
|
|
|
fetchEnd(concurrentRecord) |
|
|
|
|
return byteArray |
|
|
|
|
}else { |
|
|
|
|
val byteArray = getProxyClient(proxy).newCallResponseBody(retry) { |
|
|
|
|
addHeaders(headerMap) |
|
|
|
|
when (method) { |
|
|
|
@ -486,6 +495,7 @@ class AnalyzeUrl( |
|
|
|
|
fetchEnd(concurrentRecord) |
|
|
|
|
return byteArray |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun getByteArray(): ByteArray { |
|
|
|
|
return runBlocking { |
|
|
|
|