diff --git a/auto_pt/views.py b/auto_pt/views.py index 2c87181..19964bf 100644 --- a/auto_pt/views.py +++ b/auto_pt/views.py @@ -14,7 +14,7 @@ from pt_site import views as tasks from pt_site.UtilityTool import FileSizeConvert from pt_site.models import SiteStatus, MySite, Site, Downloader from pt_site.views import scheduler, pt_spider -from ptools.base import CommonResponse, StatusCodeEnum, DownloaderCategory +from ptools.base import CommonResponse, StatusCodeEnum, DownloaderCategory, TorrentBaseInfo def add_task(request): @@ -141,7 +141,9 @@ def get_downloading(request): 'day,', '天' ).replace(':', '小时', 1).replace(':', '分', 1).split('.')[0] + '秒' # 大小与速度处理 + torrent['state'] = TorrentBaseInfo.download_state.get(torrent.get('state')) torrent['ratio'] = '%.4f' % torrent.get('ratio') if torrent['ratio'] >= 0.0001 else 0 + torrent['progress'] = '%.4f' % torrent.get('progress') if float(torrent['progress']) < 1 else 1 torrent['uploaded'] = '' if torrent['uploaded'] == 0 else torrent['uploaded'] torrent['upspeed'] = '' if torrent['upspeed'] == 0 else torrent['upspeed'] torrent['dlspeed'] = '' if torrent['dlspeed'] == 0 else torrent['dlspeed'] diff --git a/ptools/base.py b/ptools/base.py index 1c9e661..77424ba 100644 --- a/ptools/base.py +++ b/ptools/base.py @@ -131,6 +131,29 @@ class TorrentBaseInfo: 8: '6xFree' } + download_state = { + 'allocating': '分配', + 'checkingDL': '校验中', + 'checkingResumeData': '校验恢复数据', + 'checkingUP': '', + 'downloading': '下载中', + 'error': '错误', + 'forcedDL': '强制下载', + 'forcedMetaDL': '强制下载元数据', + 'forcedUP': '强制上传', + 'metaDL': '下载元数据', + 'missingFiles': '文件丢失', + 'moving': '移动中', + 'pausedDL': '暂停下载', + 'pausedUP': '完成', + 'queuedDL': '下载队列中', + 'queuedUP': '下载队列中', + 'stalledDL': '等待下载', + 'stalledUP': '做种', + 'unknown': '未知', + 'uploading': '上传中', + } + class Trigger(models.TextChoices): # date = 'date', '单次任务'