import libtorrent as lt
import time
import sys
ses = lt.session()
ses.listen_on(6881, 6891)
params = {
'save_path': '/home',
'storage_mode': lt.storage_mode_t(2),
'paused': False,
'auto_managed': True,
'duplicate_is_error': True
}
link = "magnet:?xt=urn:btih:4fabfdfe37295ee2cb1ac2440f45e36ce022b209"
h = lt.add_magnet_uri(ses, link, params)
ses.add_dht_router("router.utorrent.com", 6881)
ses.add_dht_router("router.bittorrent.com", 6881)
ses.add_dht_router("dht.transmissionbt.com", 6881)
ses.start_dht()
while (not h.has_metadata()):
time.sleep(.1)
torinfo = h.get_torrent_info()
print torinfo.name()
print torinfo.creation_date()
print torinfo.info_hash()
print lt.make_magnet_uri(torinfo)
for tracker in torinfo.trackers():
print tracker
for x in torinfo.files():
???
关于这个 torrent_info 类文档: http: //libtorrent.org/reference-Core.html#torrent_info
因为我不懂C++,所以获取到种子文件列表。使用Python。