From b453cf9ba12b9a9138f835812df47023a186a23f Mon Sep 17 00:00:00 2001 From: ngfchl Date: Fri, 9 Dec 2022 23:11:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A8=E9=80=81=E5=88=B0Tr?= =?UTF-8?q?=E5=90=8E=E6=97=A0=E6=B3=95=E6=98=BE=E7=A4=BA=E7=A7=8D=E5=AD=90?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84bug=EF=BC=8C=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E8=BF=9B=E5=BA=A6=E6=98=BE=E7=A4=BA=EF=BC=8C=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E6=AC=A1=E6=9C=AA=E7=BB=91=E5=AE=9A=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E7=9A=84=EF=BC=8C=E5=8F=AF=E6=8E=A8=E9=80=81=E7=AC=AC=E4=BA=8C?= =?UTF-8?q?=E6=AC=A1=E5=8D=B3=E5=8F=AF=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pt_site/admin.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pt_site/admin.py b/pt_site/admin.py index 74af0d3..0869a9d 100644 --- a/pt_site/admin.py +++ b/pt_site/admin.py @@ -861,7 +861,7 @@ class TorrentInfoAdmin(AjaxAdmin): # instead of ModelAdmin def d_progress(self, obj: TorrentInfo): print(obj.hash_string) - if not obj.downloader or not obj.hash_string: + if not obj.downloader or not obj.hash_string or len(obj.hash_string) < 32: return 0 tr_client = transmission_rpc.Client( host=obj.downloader.host, @@ -875,8 +875,8 @@ class TorrentInfoAdmin(AjaxAdmin): # instead of ModelAdmin print(progress) speed = round(torrent.rateDownload / 1024 / 1024, 2) if progress < 100: - return format_html('{} MB/s', speed) - return format_html('{}%', torrent.progress) + return format_html('{} MB/s', speed) + return format_html('{}%', torrent.progress) # name_href.short_description = '种子名称' name_href.short_description = format_html( @@ -962,12 +962,15 @@ class TorrentInfoAdmin(AjaxAdmin): # instead of ModelAdmin print(torrent_info.magnet_url) print(torrent_info.site.mysite.cookie) # res = qb_client.torrents_add(torrent.magnet_url) - res = tr_client.add_torrent(torrent=torrent_info.magnet_url, - download_dir=torrent_info.save_path, - cookies=torrent_info.site.mysite.cookie) + res = tr_client.add_torrent( + torrent=torrent_info.magnet_url, + download_dir=torrent_info.save_path, + cookies=torrent_info.site.mysite.cookie + ) print(res) if isinstance(res, Torrent): - torrent_info.hash = res.id + print(res.id) + torrent_info.hash_string = res.hashString torrent_info.state = True torrent_info.downloader = downloader torrent_info.save()