Skip to content

The only downloader you need. 下载器的集大成者。

fix(m3u8): 修复开启全局限速后任务启动即失败

XiaoYouChR22e5f7977ad9
diff --git a/features/m3u8_pack/task.py b/features/m3u8_pack/task.py
index 0097d894..a593a2bd 100644
--- a/features/m3u8_pack/task.py
+++ b/features/m3u8_pack/task.py
@@ -250,7 +250,7 @@ class M3U8TaskStep(TaskStep):
if self.maxSpeed > 0:
args.append(f"--max-speed={self.maxSpeed}{self.speedUnit}")
elif cfg.isSpeedLimitEnabled.value:
- args.append(f"--max-speed={int(cfg.speedLimitation.value)}Bps")
+ args.append(f"--max-speed={int(cfg.speedLimitation.value) // 1024}K")
if self.adKeyword:
args.append(f"--ad-keyword={self.adKeyword}")
if self.shouldOmitDateInfo:
diff --git a/tests/m3u8_pack/test_task_step.py b/tests/m3u8_pack/test_task_step.py
index dbe58228..ec592592 100644
--- a/tests/m3u8_pack/test_task_step.py
+++ b/tests/m3u8_pack/test_task_step.py
@@ -4,6 +4,7 @@ from pathlib import Path
import pytest
+from app.config.cfg import cfg
from app.format import toBytes
from features.m3u8_pack.task import M3U8Task, M3U8TaskStep
@@ -144,3 +145,10 @@ def test_parse_live_record_progress_without_speed():
)
assert step.liveStatus == "Recording"
assert step.speed == 0
+
+
+def test_build_command_converts_global_speed_limit(monkeypatch):
+ monkeypatch.setattr(cfg.isSpeedLimitEnabled, "value", True)
+ monkeypatch.setattr(cfg.speedLimitation, "value", 1150976)
+ args = buildStep()._buildCommand("http://test")
+ assert "--max-speed=1124K" in args