Natarajan Ramanshankar Natarajan Ramanshankar - 1 year ago 85
Python Question

How to remove completed torrent using libtorrent rasterbar python binding?

I have a python script that downloads files using libtorrent python binding. I just want to know how to remove the torrent once the download is complete.

I'm posting here the example script I used to make mine (I'm not posting mine because it's too large, it has database parts).

import libtorrent as lt
import time

ses = lt.session()
params = { 'save_path': '/home/downloads/'}
link = "magnet:?xt=urn:btih:4MR6HU7SIHXAXQQFXFJTNLTYSREDR5EI&tr="
handle = lt.add_magnet_uri(ses, link, params)

print 'downloading metadata...'
while (not handle.has_metadata()): time.sleep(1)
print 'got metadata, starting torrent download...'
while (handle.status().state != lt.torrent_status.seeding):
print '%d %% done' % (handle.status().progress*100)


Answer Source

you call remove_torrent() on the session object, passing in the torrent_handle to remove.

In your script:


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download