Skip to content

Commit

Permalink
Merge pull request #1 from PBH-BTN/fixTorrentSize
Browse files Browse the repository at this point in the history
修正 size 为文件大小,添加实际做种大小
  • Loading branch information
azicen authored Nov 17, 2024
2 parents 28a6d01 + ee4e253 commit fef216f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
17 changes: 15 additions & 2 deletions deluge_peerbanhelperadapter/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,19 @@ def get_active_torrents_info(self):
torrent.name = deluge_torrent.get_name()
torrent.info_hash = torrent_id
torrent.progress = deluge_torrent.get_progress()
torrent.size = deluge_torrent.status.total_wanted
torrent.upload_payload_rate = deluge_torrent.status.upload_payload_rate
torrent.download_payload_rate = deluge_torrent.status.download_payload_rate

# LT torrent_info
torrent_info = deluge_torrent.handle.torrent_file()
torrent.size = torrent_info.total_size()
torrent.priv = torrent_info.priv()
piece_length = torrent_info.piece_length()

# LT torrent_status
torrent_status = deluge_torrent.handle.status()
torrent.completed_size = torrent_status.num_pieces * piece_length

# LT peer_info
lt_peers = deluge_torrent.handle.get_peer_info()
peers = []
Expand Down Expand Up @@ -208,10 +215,16 @@ def get_torrents_info(self):
torrent.name = deluge_torrent.get_name()
torrent.info_hash = torrent_id
torrent.progress = deluge_torrent.get_progress()
torrent.size = deluge_torrent.status.total_wanted

# LT torrent_info
torrent_info = deluge_torrent.handle.torrent_file()
torrent.size = torrent_info.total_size()
torrent.priv = torrent_info.priv()
piece_length = torrent_info.piece_length()

# LT torrent_status
torrent_status = deluge_torrent.handle.status()
torrent.completed_size = torrent_status.num_pieces * piece_length

torrents.append(torrent.dist())

Expand Down
3 changes: 3 additions & 0 deletions deluge_peerbanhelperadapter/model/torrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ class Torrent(BaseModel):
# 种子大小
size: int = 0

# 种子实际做种大小
completed_size: int = 0

# 是否为私有种子
priv: bool = False

Expand Down

0 comments on commit fef216f

Please sign in to comment.