diff --git a/torrent-client/torrent_downloader.py b/torrent-client/torrent_downloader.py index b5280260..a098f7db 100644 --- a/torrent-client/torrent_downloader.py +++ b/torrent-client/torrent_downloader.py @@ -158,8 +158,34 @@ class TorrentDownloader: } if status.progress == 1: - torrent_handle.pause() - self.session.remove_torrent(torrent_handle) self.downloading_game_id = -1 return response + + def get_seed_status(self): + response = [] + + for game_id, torrent_handle in self.torrent_handles.items(): + if game_id == self.downloading_game_id: + continue + + status = torrent_handle.status() + info = torrent_handle.torrent_file() + + torrent_info = { + 'folderName': info.name() if info else "", + 'fileSize': info.total_size() if info else 0, + 'gameId': game_id, + 'progress': status.progress, + 'downloadSpeed': status.download_rate, + 'uploadSpeed': status.upload_rate, + 'numPeers': status.num_peers, + 'numSeeds': status.num_seeds, + 'status': status.state, + 'bytesDownloaded': status.progress * info.total_size() if info else status.all_time_download, + } + + if status.state == 5: + response.append(torrent_info) + + return response