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()