分片数优化
This commit is contained in:
parent
8a5d18dbb1
commit
01e9b00a36
|
|
@ -18,7 +18,7 @@ import java.util.Vector
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
|
||||||
object DownloadMT {
|
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>>();
|
private val infos = mutableMapOf<String, Array<Any>>();
|
||||||
|
|
||||||
|
|
@ -75,9 +75,9 @@ object DownloadMT {
|
||||||
SpiderDebug.log("--文件总大小:$total")
|
SpiderDebug.log("--文件总大小:$total")
|
||||||
|
|
||||||
//如果文件太小,也不走代理
|
//如果文件太小,也不走代理
|
||||||
if (total.toLong() < 1024 * 1024 * 64) {
|
/* if (total.toLong() < 1024 * 1024 * 100) {
|
||||||
return ProxyVideo.proxy(url, headers)
|
return proxy(url, headers)
|
||||||
}
|
}*/
|
||||||
var range =
|
var range =
|
||||||
if (StringUtils.isAllBlank(headers["range"])) headers["Range"] else headers["range"]
|
if (StringUtils.isAllBlank(headers["range"])) headers["Range"] else headers["range"]
|
||||||
if (StringUtils.isAllBlank(range)) range = "bytes=0-";
|
if (StringUtils.isAllBlank(range)) range = "bytes=0-";
|
||||||
|
|
@ -155,11 +155,10 @@ object DownloadMT {
|
||||||
|
|
||||||
fun generatePart(rangeObj: Map<String?, String>, total: String): List<LongArray> {
|
fun generatePart(rangeObj: Map<String?, String>, total: String): List<LongArray> {
|
||||||
val totalSize = total.toLong()
|
val totalSize = total.toLong()
|
||||||
//超过10GB,分块是80MB,不然是16MB
|
//超过10GB,分块是80Mb,不然是16MB
|
||||||
val partSize =
|
val partSize =
|
||||||
if (totalSize > 1024L * 1024L * 1024L * 10L) 1024 * 1024 * 8 * 10L else 1024 * 1024 * 8 * 2L
|
if (totalSize > 8L * 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
|
|
||||||
var start = rangeObj["start"]!!.toLong()
|
var start = rangeObj["start"]!!.toLong()
|
||||||
var end =
|
var end =
|
||||||
if (StringUtils.isAllBlank(rangeObj["end"])) start + partSize else rangeObj["end"]!!.toLong()
|
if (StringUtils.isAllBlank(rangeObj["end"])) start + partSize else rangeObj["end"]!!.toLong()
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
ca49e8939240a5851b24f58461c82ef9
|
848c7528f18727d12cc591e6de830caa
|
||||||
|
|
|
||||||
|
|
@ -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": [
|
"lives": [
|
||||||
{
|
{
|
||||||
"name": "电视直播",
|
"name": "电视直播",
|
||||||
|
|
|
||||||
|
|
@ -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": [
|
"lives": [
|
||||||
{
|
{
|
||||||
"name": "电视直播",
|
"name": "电视直播",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue