From a64ee2242c166f90d761682c83f28edea102178e Mon Sep 17 00:00:00 2001 From: Kelvin <kelvin@futo.org> Date: Thu, 29 Aug 2024 20:28:16 +0200 Subject: [PATCH] Max download parallelism setting --- .../api/media/platforms/js/SourcePluginConfig.kt | 1 + .../com/futo/platformplayer/downloads/VideoDownload.kt | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/futo/platformplayer/api/media/platforms/js/SourcePluginConfig.kt b/app/src/main/java/com/futo/platformplayer/api/media/platforms/js/SourcePluginConfig.kt index 3d57cb41..bd3c2ded 100644 --- a/app/src/main/java/com/futo/platformplayer/api/media/platforms/js/SourcePluginConfig.kt +++ b/app/src/main/java/com/futo/platformplayer/api/media/platforms/js/SourcePluginConfig.kt @@ -50,6 +50,7 @@ class SourcePluginConfig( var primaryClaimFieldType: Int? = null, var developerSubmitUrl: String? = null, var allowAllHttpHeaderAccess: Boolean = false, + var maxDownloadParallelism: Int = 0 ) : IV8PluginConfig { val absoluteIconUrl: String? get() = resolveAbsoluteUrl(iconUrl, sourceUrl); diff --git a/app/src/main/java/com/futo/platformplayer/downloads/VideoDownload.kt b/app/src/main/java/com/futo/platformplayer/downloads/VideoDownload.kt index b7beef43..2fdc1848 100644 --- a/app/src/main/java/com/futo/platformplayer/downloads/VideoDownload.kt +++ b/app/src/main/java/com/futo/platformplayer/downloads/VideoDownload.kt @@ -27,6 +27,8 @@ import com.futo.platformplayer.api.media.models.video.IPlatformVideo import com.futo.platformplayer.api.media.models.video.IPlatformVideoDetails import com.futo.platformplayer.api.media.models.video.SerializedPlatformVideo import com.futo.platformplayer.api.media.models.video.SerializedPlatformVideoDetails +import com.futo.platformplayer.api.media.platforms.js.JSClient +import com.futo.platformplayer.api.media.platforms.js.SourcePluginConfig import com.futo.platformplayer.api.media.platforms.js.models.JSRequestExecutor import com.futo.platformplayer.api.media.platforms.js.models.JSVideo import com.futo.platformplayer.api.media.platforms.js.models.sources.IJSDashManifestRawSource @@ -42,6 +44,7 @@ import com.futo.platformplayer.parsers.HLS import com.futo.platformplayer.serializers.OffsetDateTimeNullableSerializer import com.futo.platformplayer.states.StateDownloads import com.futo.platformplayer.states.StatePlatform +import com.futo.platformplayer.states.StatePlugins import com.futo.platformplayer.toHumanBitrate import com.futo.platformplayer.toHumanBytesSpeed import hasAnySource @@ -703,9 +706,12 @@ class VideoDownload { try{ val head = client.tryHead(videoUrl); + val relatedPlugin = (video?.url ?: videoDetails?.url)?.let { StatePlatform.instance.getContentClient(it) }?.let { if(it is JSClient) it else null }; if(Settings.instance.downloads.byteRangeDownload && head?.containsKey("accept-ranges") == true && head.containsKey("content-length")) { - val concurrency = Settings.instance.downloads.getByteRangeThreadCount(); + val maxParallel = if(relatedPlugin != null && relatedPlugin.config.maxDownloadParallelism > 0) + relatedPlugin.config.maxDownloadParallelism else 99; + val concurrency = Math.min(maxParallel, Settings.instance.downloads.getByteRangeThreadCount()); Logger.i(TAG, "Download $name ByteRange Parallel (${concurrency}): " + videoUrl); sourceLength = head["content-length"]!!.toLong(); onProgress(sourceLength, 0, 0); -- GitLab