如何使用libtorrent rasterbar python binding删除已完成的torrent?

时间:2017-02-07 00:05:15

标签: python libtorrent libtorrent-rasterbar

我有一个使用libtorrent python绑定下载文件的python脚本。我只是想知道如何在下载完成后删除torrent。

我在这里发布了我曾经制作过的示例脚本(我不会发布我的,因为它太大了,它有数据库部分)。

import libtorrent as lt
import time

ses = lt.session()
params = { 'save_path': '/home/downloads/'}
link = "magnet:?xt=urn:btih:4MR6HU7SIHXAXQQFXFJTNLTYSREDR5EI&tr=http://tracker.vodo.net:6970/announce"
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)
    time.sleep(1)

感谢。

1 个答案:

答案 0 :(得分:1)

你在会话对象上调用remove_torrent(),传入torrent_handle以删除。

http://libtorrent.org/reference-Core.html#remove_torrent()

在你的剧本中:

ses.remove_torrent(handle)

相关问题