From 129700c1cf7deba7b5088934b365f67e24d38ff7 Mon Sep 17 00:00:00 2001 From: ngfchl Date: Sun, 18 Sep 2022 17:32:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=AE=A1=E7=90=86=E7=BB=A7?= =?UTF-8?q?=E7=BB=AD=E8=BF=9B=E8=A1=8C=E4=B8=AD=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E9=80=9F=E5=BA=A6=E5=88=B03-5=E7=A7=92?= =?UTF-8?q?=EF=BC=8C=E5=8F=8C=E5=87=BB=E8=A1=A8=E6=A0=BC=E5=8F=AF=E5=BC=B9?= =?UTF-8?q?=E5=87=BA=E8=AF=A6=E6=83=85=E9=A1=B5=EF=BC=88=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E8=BF=98=E6=9C=AA=E4=BC=98=E5=8C=96=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auto_pt/views.py | 24 ++- templates/auto_pt/downloading.html | 296 +++++++++++++++++------------ 2 files changed, 190 insertions(+), 130 deletions(-) diff --git a/auto_pt/views.py b/auto_pt/views.py index 7cab239..5888db6 100644 --- a/auto_pt/views.py +++ b/auto_pt/views.py @@ -12,7 +12,7 @@ from django.shortcuts import render from pt_site import views as tasks from pt_site.models import SiteStatus, MySite, Site, Downloader from pt_site.views import scheduler, pt_spider -from ptools.base import CommonResponse, StatusCodeEnum +from ptools.base import CommonResponse, StatusCodeEnum, DownloaderCategory def add_task(request): @@ -87,7 +87,7 @@ def page_downloading(request): def get_downloader(request): - downloader_list = Downloader.objects.values('id', 'name', 'host') + downloader_list = Downloader.objects.filter(category=DownloaderCategory.qBittorrent).values('id', 'name', 'host') return JsonResponse(CommonResponse.success(data=list(downloader_list)).to_dict(), safe=False) @@ -96,19 +96,17 @@ def get_downloading(request): print(id) downloader = Downloader.objects.filter(id=id).first() - qb_client = qbittorrentapi.Client(host=downloader.host, - port=downloader.port, - username=downloader.username, - password=downloader.password) + qb_client = qbittorrentapi.Client( + host=downloader.host, + port=downloader.port, + username=downloader.username, + password=downloader.password, + SIMPLE_RESPONSES=True + ) try: qb_client.auth_log_in() - t_list = qb_client.torrents_info() - print(len(t_list)) - torrents = [] - for torrent in t_list: - # torrent.to_dict() - torrents.append(dict(torrent)) - print(torrents) + torrents = qb_client.torrents_info() + print(len(torrents)) return JsonResponse(CommonResponse.success(data=torrents).to_dict(), safe=False) except Exception as e: print(e) diff --git a/templates/auto_pt/downloading.html b/templates/auto_pt/downloading.html index d81dab8..8676c6d 100644 --- a/templates/auto_pt/downloading.html +++ b/templates/auto_pt/downloading.html @@ -17,23 +17,23 @@ {# :name="downloader.id"#} :id="downloader.id"> - - 操作 - - - 继续 - 暂停 - 强制继续 - 删除 - 限速 - 分类 - 更改路径 - 自动管理 - 重新校验 - 复制链接 - 复制HASH - - + + 操作 + + + 继续 + 暂停 + 强制继续 + 删除 + 限速 + 分类 + 更改路径 + 自动管理 + 重新校验 + 复制链接 + 复制HASH + + - #} @@ -94,118 +94,180 @@ {# label="Tracker">#} - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {% include 'admin/includes/js-part.html' %} \ No newline at end of file