我正在使用 libtorrent 1.0.9 和自定义绑定(可使用 python 重现)。有时我无法下载磁铁,因为它们在没有元数据的情况下被卡住(虽然有超过 200 个 DHT 节点可用)。我可以用这个磁铁重现这个问题:
magnet:?xt=urn:btih:565DB305A27FFB321FCC7B064AFD7BD73AEDDA2B&dn=bbb_sunflower_1080p_60fps_normal.mp4&tr=udp%3a%2f%2ftracker.openbittorrent.com%3a80%2fannounce&tr=udp%3a%2f%2ftracker.publicbt.com%3a80%2fannounce&ws=http%3a%2f%2fdistribution.bbb3d.renderfarming.net%2fvideo%2fmp4%2fbbb_sunflower_1080p_60fps_normal.mp4
与此同时,在其他 torrent 客户端(qBittorrent、Vuze)中,它可以非常快速地获取元数据。可以使用以下代码重现:
import libtorrent as lt
import time
session = lt.session()
session.listen_on(6881, 6891)
session.add_extension('ut_metadata')
session.add_extension('ut_pex')
session.add_extension('metadata_transfer')
session.add_dht_router("router.utorrent.com", 6881)
session.add_dht_router("router.bittorrent.com", 6881)
session.add_dht_router("dht.transmissionbt.com", 6881)
session.add_dht_router("dht.aelitis.com", 6881)
session.start_dht()
session.start_lsd()
session.start_upnp()
session.start_natpmp()
params = { 'save_path': '/tmp/'}
link ="magnet:?xt=urn:btih:565DB305A27FFB321FCC7B064AFD7BD73AEDDA2B&dn=bbb_sunflower_1080p_60fps_normal.mp4&tr=udp%3a%2f%2ftracker.openbittorrent.com%3a80%2fannounce&tr=udp%3a%2f%2ftracker.publicbt.com%3a80%2fannounce&ws=http%3a%2f%2fdistribution.bbb3d.renderfarming.net%2fvideo%2fmp4%2fbbb_sunflower_1080p_60fps_normal.mp4"
handle = lt.add_magnet_uri(session, link, params)
print('downloading metadata...')
while (not handle.has_metadata()):
status=session.status()
print('dht nodes: ', status.dht_nodes)
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)
我做错了什么?