While extending AutoRemovePlus plugin I've come across an oddity around seed time. Looks like force_announce() of a torrent updates the seed_time. Does this mean force_announce() asks for this value from the tracker, as opposed to updating tracker with the values Deluge has? How to access up-to-date seed_time data? Who has it to begin with?
Following code excerpt is taken from the plugin, demonstrating what's happening:
Code: Select all
def reannounce(self, tid, t):
# note the first two announce_* arg values are the defaults from https://libtorrent.org/reference-Torrent_Handle.html#force_reannounce()
announce_seconds = 0 # how many seconds from now to issue the tracker announces; default = 0
announce_trkr_idx = -1 # specifies which tracker to re-announce. If set to -1 (which is the default), all trackers are re-announced.
announce_flags = 1
try:
t.handle.force_reannounce(announce_seconds, announce_trkr_idx, announce_flags)
log.error("AutoRemovePlus.reannounce(): forced reannounce OK for torrent [%s]", tid)
return True
except Exception as e:
log.error(
"AutoRemovePlus.reannounce(): Problems calling libtorrent.torr.force_reannounce(): %s", e
)
return False
def remove_torrent(self, tid, torrent, remove_data):
seed_time = torrent.get_status(['seeding_time'])['seeding_time']
seed_time_h = _get_seed_time((tid, torrent))
log.error("remove_torrent(): pre-announce seed_time: [%s], h: [%s]", seed_time, seed_time_h)
# update trackers to make sure the latest upload amount & time are reflected
# prior to nuking torrent.
if not self.reannounce(tid, torrent):
log.error(
"AutoRemovePlus.remove_torrent(): reannounce failed for torrent: [%s]; skipping remove", tid)
return False
log.error("Running remove_torrent() for [{}] with remove data = {}".format(tid, remove_data))
try:
self.torrentmanager.remove(tid, remove_data=remove_data)
seed_time = torrent.get_status(['seeding_time'])['seeding_time']
seed_time_h = _get_seed_time((tid, torrent))
age_sec = time.time() - torrent.time_added
# note these 2 total_time_* are in bytes, not time values:
total_time_uploaded = torrent.get_status(['total_uploaded'])['total_uploaded'] # in deluge's internal status, it's under status.all_time_upload
total_time_downloaded = torrent.get_status(['all_time_download'])['all_time_download']
log.error("remove_torrent(): successfully removed torrent: [%s]. seed_time: [%s], h: [%s], ratio: %s, age_sec: [%s], total_time_up: [%s], total_time_down: [%s]",
tid, seed_time, seed_time_h, torrent.get_ratio(), age_sec, total_time_uploaded, total_time_downloaded)
except Exception as e:
log.warning(
"remove_torrent(): AutoRemovePlus: Problems removing torrent [%s]: %s", tid, e
)
Code: Select all
remove_torrent(): pre-announce seed_time: [632251], h: [175.6253]
AutoRemovePlus.reannounce(): forced reannounce OK for torrent [78616b03e471bca7d8ce9597b6c55fca00ee42e1]
Running remove_torrent() for [78616b03e471bca7d8ce9597b6c55fca00ee42e1] with remove data = True
remove_torrent(): successfully removed torrent: [78616b03e471bca7d8ce9597b6c55fca00ee42e1]. seed_time: [571045], h: [158.6236], ratio: 0.328677713114, age_sec: [633576.046782], total_time_up: [7246677822], total_time_down: [22068859177]
What's going on here?