mirror of
https://github.com/ngfchl/ptools
synced 2023-07-10 13:41:22 +08:00
格式化部分下载任务字段,优化显示
This commit is contained in:
@@ -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']
|
||||
|
||||
@@ -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', '单次任务'
|
||||
|
||||
Reference in New Issue
Block a user