|
|
|
@ -6,10 +6,13 @@ import androidx.annotation.Keep |
|
|
|
|
import io.legado.app.constant.AppConst.dateFormat |
|
|
|
|
import io.legado.app.help.http.CookieStore |
|
|
|
|
import io.legado.app.help.http.SSLHelper |
|
|
|
|
import io.legado.app.help.http.StrResponse |
|
|
|
|
import io.legado.app.model.Debug |
|
|
|
|
import io.legado.app.model.analyzeRule.AnalyzeUrl |
|
|
|
|
import io.legado.app.model.analyzeRule.QueryTTF |
|
|
|
|
import io.legado.app.utils.* |
|
|
|
|
import kotlinx.coroutines.ExperimentalCoroutinesApi |
|
|
|
|
import kotlinx.coroutines.async |
|
|
|
|
import kotlinx.coroutines.runBlocking |
|
|
|
|
import org.jsoup.Connection |
|
|
|
|
import org.jsoup.Jsoup |
|
|
|
@ -40,6 +43,26 @@ interface JsExtensions { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 并发访问网络 |
|
|
|
|
*/ |
|
|
|
|
@ExperimentalCoroutinesApi |
|
|
|
|
fun fetchAll(urlList: List<String>): Array<StrResponse?> { |
|
|
|
|
return runBlocking { |
|
|
|
|
val asyncArray = Array(urlList.size) { |
|
|
|
|
async { |
|
|
|
|
val url = urlList[it] |
|
|
|
|
val analyzeUrl = AnalyzeUrl(url) |
|
|
|
|
analyzeUrl.getStrResponse(url) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
val resArray = Array<StrResponse?>(urlList.size) { |
|
|
|
|
asyncArray[it].await() |
|
|
|
|
} |
|
|
|
|
resArray |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 访问网络,返回Response<String> |
|
|
|
|
*/ |
|
|
|
|