Merge branch 'jxxghp:main' into main

This commit is contained in:
DDSDerek 2023-08-13 14:09:29 +08:00 committed by GitHub
commit 2a47d5f172
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 16 deletions

View File

@ -489,7 +489,7 @@ class BestFilmVersion(_PluginBase):
"poster": mediainfo.get_poster_image(),
"overview": mediainfo.overview,
"tmdbid": mediainfo.tmdb_id,
"time": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
"time": datetime.now().strftime("%Y-%m-%d %H:%M:%S")
})
# 保存历史记录
self.save_data('history', history)
@ -668,7 +668,7 @@ class BestFilmVersion(_PluginBase):
"poster": mediainfo.get_poster_image(),
"overview": mediainfo.overview,
"tmdbid": mediainfo.tmdb_id,
"time": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
"time": datetime.now().strftime("%Y-%m-%d %H:%M:%S")
})
# 保存历史记录
self.save_data('history', history)

View File

@ -50,6 +50,8 @@ class SpeedLimiter(_PluginBase):
_play_down_speed: float = 0
_noplay_up_speed: float = 0
_noplay_down_speed: float = 0
# 当前限速状态
_current_state = ""
def init_plugin(self, config: dict = None):
# 读取配置
@ -330,6 +332,13 @@ class SpeedLimiter(_PluginBase):
"""
if not self._qb and not self._tr:
return
state = f"U:{upload_limit},D:{download_limit}"
if self._current_state == state:
# 限速状态没有改变
return
else:
self._current_state = state
if upload_limit:
text = f"上传:{upload_limit} KB/s"
else:
@ -342,23 +351,39 @@ class SpeedLimiter(_PluginBase):
if self._qb:
self._qb.set_speed_limit(download_limit=download_limit, upload_limit=upload_limit)
# 发送通知
if self._notify and (upload_limit or download_limit):
title = f"Qbittorrent 开始{limit_type}限速"
self.post_message(
mtype=NotificationType.MediaServer,
title=title,
text=text
)
if self._notify:
title = "【播放限速】"
if upload_limit or download_limit:
subtitle = f"Qbittorrent 开始{limit_type}限速"
self.post_message(
mtype=NotificationType.MediaServer,
title=title,
text=f"{subtitle}\n{text}"
)
else:
self.post_message(
mtype=NotificationType.MediaServer,
title=title,
text=f"Qbittorrent 已取消限速"
)
if self._tr:
self._tr.set_speed_limit(download_limit=download_limit, upload_limit=upload_limit)
# 发送通知
if self._notify and (upload_limit or download_limit):
title = f"Transmission 开始{limit_type}限速"
self.post_message(
mtype=NotificationType.MediaServer,
title=title,
text=text
)
if self._notify:
title = "【播放限速】"
if upload_limit or download_limit:
subtitle = f"Transmission 开始{limit_type}限速"
self.post_message(
mtype=NotificationType.MediaServer,
title=title,
text=f"{subtitle}\n{text}"
)
else:
self.post_message(
mtype=NotificationType.MediaServer,
title=title,
text=f"Transmission 已取消限速"
)
except Exception as e:
logger.error(f"设置限速失败:{str(e)}")