fix 正在下载显示剩余下载时间

This commit is contained in:
thsrite 2023-10-27 16:52:47 +08:00
parent 26cd2c6cfe
commit 070481cab0
5 changed files with 22 additions and 1 deletions

View File

@ -165,6 +165,8 @@ class QbittorrentModule(_ModuleBase):
state="paused" if torrent.get('state') == "paused" else "downloading",
dlspeed=StringUtils.str_filesize(torrent.get('dlspeed')),
upspeed=StringUtils.str_filesize(torrent.get('upspeed')),
left_time=StringUtils.str_secends(
(torrent.get('total_size') - torrent.get('completed')) / torrent.get('dlspeed'))
))
else:
return None

View File

@ -151,6 +151,7 @@ class TransmissionModule(_ModuleBase):
state="paused" if torrent.status == "stopped" else "downloading",
dlspeed=StringUtils.str_filesize(dlspeed),
upspeed=StringUtils.str_filesize(upspeed),
left_time=StringUtils.str_secends(torrent.left_until_done / dlspeed)
))
else:
return None

View File

@ -289,7 +289,7 @@ class MediaSyncDel(_PluginBase):
{
'component': 'VAlert',
'props': {
'text': '关于路径映射'
'text': '关于路径映射(转移后文件)'
'emby:/data/series/A.mp4,'
'moviepilot:/mnt/link/series/A.mp4。'
'路径映射填/data:/mnt/link。'

View File

@ -31,6 +31,7 @@ class DownloadingTorrent(BaseModel):
dlspeed: Optional[str] = None
media: Optional[dict] = {}
userid: Optional[str] = None
left_time: Optional[str] = None
class TransferInfo(BaseModel):

View File

@ -63,6 +63,23 @@ class StringUtils:
b, u = d[index]
return str(round(time_sec / (b + 1))) + u
@staticmethod
def str_secends(time_sec: Union[str, int, float]) -> str:
"""
将秒转为时分秒字符串
"""
hours = time_sec // 3600
remainder_seconds = time_sec % 3600
minutes = remainder_seconds // 60
seconds = remainder_seconds % 60
time: str = str(int(seconds)) + ''
if minutes:
time = str(int(minutes)) + '' + time
if hours:
time = str(int(hours)) + '' + time
return time
@staticmethod
def is_chinese(word: Union[str, list]) -> bool:
"""