分片数优化

This commit is contained in:
lushunming 2025-07-15 15:24:39 +08:00
parent 8a5d18dbb1
commit 01e9b00a36
5 changed files with 10 additions and 11 deletions

View File

@ -18,7 +18,7 @@ import java.util.Vector
import kotlin.math.min
object DownloadMT {
private var THREAD_NUM: Int = Runtime.getRuntime().availableProcessors() * 2
private val THREAD_NUM: Int = Runtime.getRuntime().availableProcessors() * 2
private val infos = mutableMapOf<String, Array<Any>>();
@ -75,9 +75,9 @@ object DownloadMT {
SpiderDebug.log("--文件总大小:$total")
//如果文件太小,也不走代理
if (total.toLong() < 1024 * 1024 * 64) {
return ProxyVideo.proxy(url, headers)
}
/* if (total.toLong() < 1024 * 1024 * 100) {
return proxy(url, headers)
}*/
var range =
if (StringUtils.isAllBlank(headers["range"])) headers["Range"] else headers["range"]
if (StringUtils.isAllBlank(range)) range = "bytes=0-";
@ -155,11 +155,10 @@ object DownloadMT {
fun generatePart(rangeObj: Map<String?, String>, total: String): List<LongArray> {
val totalSize = total.toLong()
//超过10GB分块是80MB不然是16MB
//超过10GB分块是80Mb不然是16MB
val partSize =
if (totalSize > 1024L * 1024L * 1024L * 10L) 1024 * 1024 * 8 * 10L else 1024 * 1024 * 8 * 2L
THREAD_NUM = if (totalSize > 1024L * 1024L * 1024L * 10L) 64 else Runtime.getRuntime()
.availableProcessors() * 2
if (totalSize > 8L * 1024L * 1024L * 1024L * 10L) 1024 * 1024 * 8 * 10L else 1024 * 1024 * 8 * 2L
var start = rangeObj["start"]!!.toLong()
var end =
if (StringUtils.isAllBlank(rangeObj["end"])) start + partSize else rangeObj["end"]!!.toLong()

Binary file not shown.

View File

@ -1 +1 @@
ca49e8939240a5851b24f58461c82ef9
848c7528f18727d12cc591e6de830caa

View File

@ -1,5 +1,5 @@
{
"spider": "https://andoridspidermt.netlify.app/jar/custom_spider.jar;md5;ca49e8939240a5851b24f58461c82ef9",
"spider": "https://andoridspidermt.netlify.app/jar/custom_spider.jar;md5;848c7528f18727d12cc591e6de830caa",
"lives": [
{
"name": "电视直播",

View File

@ -1,5 +1,5 @@
{
"spider": "https://ghproxy.net/https://raw.githubusercontent.com/lushunming/AndroidCatVodSpider/multiThreadkt/jar/custom_spider.jar;md5;ca49e8939240a5851b24f58461c82ef9",
"spider": "https://ghproxy.net/https://raw.githubusercontent.com/lushunming/AndroidCatVodSpider/multiThreadkt/jar/custom_spider.jar;md5;848c7528f18727d12cc591e6de830caa",
"lives": [
{
"name": "电视直播",