From a89bda961bead140942ffda0b5c12e30c3a10607 Mon Sep 17 00:00:00 2001 From: Doubly <1286398734@qq.com> Date: Sat, 26 Oct 2024 20:27:48 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E5=A4=9A?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E5=99=A8=E6=97=B6=EF=BC=8C=E6=AF=94=E4=BE=8B?= =?UTF-8?q?=E5=88=86=E9=85=8D=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 ++- plugins/speedlimiter/__init__.py | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index b726740..f5b36a6 100644 --- a/package.json +++ b/package.json @@ -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": "增加不限速路径配置,以应对网盘直链播放的情况" } }, diff --git a/plugins/speedlimiter/__init__.py b/plugins/speedlimiter/__init__.py index 517f683..b59d291 100644 --- a/plugins/speedlimiter/__init__.py +++ b/plugins/speedlimiter/__init__.py @@ -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 = "【播放限速】"