feat: seed after doenload

This commit is contained in:
Hachi-R 2024-11-08 18:24:06 -03:00
parent 21ca26dcfe
commit 9c9c0e6c09

View File

@ -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