fix:修复多下载器时,比例分配错误问题

This commit is contained in:
Doubly
2024-10-26 20:27:48 +08:00
parent 5e136cd785
commit a89bda961b
2 changed files with 8 additions and 6 deletions

View File

@@ -182,11 +182,12 @@
"name": "播放限速",
"description": "外网播放媒体库视频时,自动对下载器进行限速。",
"labels": "网络",
"version": "1.2",
"version": "1.2.1",
"icon": "Librespeed_A.png",
"author": "Shurelol",
"level": 1,
"history": {
"v1.2.1": "修复多下载器时限速比例计算错误问题",
"v1.2": "增加不限速路径配置,以应对网盘直链播放的情况"
}
},

View File

@@ -23,7 +23,7 @@ class SpeedLimiter(_PluginBase):
# 插件图标
plugin_icon = "Librespeed_A.png"
# 插件版本
plugin_version = "1.2"
plugin_version = "1.2.1"
# 插件作者
plugin_author = "Shurelol"
# 作者主页
@@ -555,23 +555,26 @@ class SpeedLimiter(_PluginBase):
try:
cnt = 0
for download in self._downloader:
upload_limit_final = 0
if self._auto_limit and limit_type == "播放":
# 开启了播放智能限速
if len(self._downloader) == 1:
# 只有一个下载器
upload_limit = int(upload_limit)
upload_limit_final = int(upload_limit)
else:
# 多个下载器
if not self._allocation_ratio:
# 平均
upload_limit = int(upload_limit / len(self._downloader))
upload_limit_final = int(upload_limit / len(self._downloader))
else:
# 按比例
allocation_count = sum([int(i) for i in self._allocation_ratio.split(":")])
upload_limit = int(upload_limit * int(self._allocation_ratio.split(":")[cnt]) / allocation_count)
upload_limit_final = int(upload_limit * int(self._allocation_ratio.split(":")[cnt]) / allocation_count)
cnt += 1
if upload_limit:
text = f"上传:{upload_limit} KB/s"
if upload_limit_final:
else:
text = f"上传:未限速"
if download_limit:
@@ -580,7 +583,6 @@ class SpeedLimiter(_PluginBase):
text = f"{text}\n下载:未限速"
if str(download) == 'qbittorrent':
if self._qb:
self._qb.set_speed_limit(download_limit=download_limit, upload_limit=upload_limit)
# 发送通知
if self._notify:
title = "【播放限速】"
@@ -599,7 +601,6 @@ class SpeedLimiter(_PluginBase):
)
else:
if self._tr:
self._tr.set_speed_limit(download_limit=download_limit, upload_limit=upload_limit)
# 发送通知
if self._notify:
title = "【播放限速】"