mirror of
https://github.com/ngfchl/ptools
synced 2023-07-10 13:41:22 +08:00
1. 优化已实现的种子控制功能
2. 从下载器获取更多信息,开始逐步展示
This commit is contained in:
@@ -107,12 +107,17 @@ def get_downloading(request):
|
||||
)
|
||||
try:
|
||||
qb_client.auth_log_in()
|
||||
torrents = qb_client.torrents_info()
|
||||
transfer = qb_client.transfer_info()
|
||||
# transfer = qb_client.transfer_info()
|
||||
# torrents = qb_client.torrents_info()
|
||||
main_data = qb_client.sync_maindata()
|
||||
print(transfer)
|
||||
print(json.dumps(main_data))
|
||||
for torrent in torrents:
|
||||
torrent_list = main_data.get('torrents')
|
||||
print(type(torrent_list))
|
||||
# print(json.dumps(main_data))
|
||||
torrents = []
|
||||
for index, torrent in torrent_list.items():
|
||||
# print(type(torrent))
|
||||
# print(torrent)
|
||||
# torrent = json.loads(torrent)
|
||||
# 时间处理
|
||||
# 添加于
|
||||
torrent['added_on'] = datetime.fromtimestamp(torrent.get('added_on')).strftime(
|
||||
@@ -149,10 +154,15 @@ def get_downloading(request):
|
||||
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']
|
||||
torrent['hash'] = index
|
||||
torrents.append(torrent)
|
||||
print(len(torrents))
|
||||
return JsonResponse(CommonResponse.success(data=torrents).to_dict(), safe=False)
|
||||
main_data['torrents'] = torrents
|
||||
# return JsonResponse(CommonResponse.success(data=torrents).to_dict(), safe=False)
|
||||
return JsonResponse(CommonResponse.success(data=main_data).to_dict(), safe=False)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
# raise
|
||||
return JsonResponse(CommonResponse.error(
|
||||
msg='连接下载器出错咯!'
|
||||
).to_dict(), safe=False)
|
||||
@@ -178,7 +188,7 @@ def control_torrent(request):
|
||||
# 根据指令字符串定位函数
|
||||
command_exec = getattr(qb_client.torrents, command)
|
||||
print(command_exec)
|
||||
command_exec(torrent_hashes=ids.split(','))
|
||||
command_exec(torrent_hashes=ids.split(','), enable=True)
|
||||
# 延缓2秒等待操作生效
|
||||
time.sleep(2)
|
||||
except Exception as e:
|
||||
|
||||
@@ -391,9 +391,10 @@
|
||||
console.log('获取下载器列表成功', res.data)
|
||||
if (res.data.code === 0) {
|
||||
this.downloaders = res.data.data
|
||||
console.log(this.torrents)
|
||||
this.downloader_id = this.downloaders[0].id
|
||||
this.get_downloading(this.downloader_id)
|
||||
console.log(this.torrents.length)
|
||||
{#console.log(this.torrents.length)#}
|
||||
this.loading = false
|
||||
} else {
|
||||
this.loading = false
|
||||
@@ -435,15 +436,15 @@
|
||||
}
|
||||
}
|
||||
).then(res => {
|
||||
{#console.log(res.data.data.torrents)#}
|
||||
if (res.data.code === 0) {
|
||||
console.log(res.data.data.length)
|
||||
this.torrents = res.data.data
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '任务加载成功!!'
|
||||
})
|
||||
this.torrents = res.data.data.torrents
|
||||
//this.$message({
|
||||
// type: 'success',
|
||||
// message: '任务加载成功!!'
|
||||
//})
|
||||
} else {
|
||||
console.log(res.data.data)
|
||||
{#console.log(res.data.data)#}
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: '任务加载出错!!'
|
||||
|
||||
Reference in New Issue
Block a user