我正在寻找如何在 libtorrent 中使用磁力链接期间在 torrent_info() 函数中传递参数。 特别是我的目标是分析同行和作品。通过使用 .torrent 文件,这个过程很明显会抛出该站点中的其他给定范例:
e = lt.bdecode(open("torrent.torrent", 'rb').read())
info = lt.torrent_info(e)
但是磁力链接会发生什么?
params = {
'save_path': 'C:\Python26',
'storage_mode': lt.storage_mode_t(2),
'paused': False,
'auto_managed': True,
'duplicate_is_error': True}
link = "magnet:?........."
handle = lt.add_magnet_uri(ses, link, params)
为了能够正确使用 torrent_info 功能,哪个变量相当于磁力链接情况下 .torrent 进程的“e”?
最佳答案
添加磁力链接可为您提供一个 Torrent 句柄,您可以从中获取 Torrent 信息(一旦获取了元数据 - 否则它将抛出)。
与元数据已经存在的 torrent 文件不同,磁力链接需要先从网络检索元数据,这可能需要一些时间。
我更习惯于 C++ 库,但是好吧 - 要在最脏的情况下演示它,您可以按照以下方式做一些事情:
handle = lt.add_magnet_uri(ses, link, params)
while (not handle.has_metadata()):
time.sleep(.1)
info = handle.get_torrent_info()
... 然后,您可以在这里阅读所有相关内容;) http://www.rasterbar.com/products/libtorrent/manual.html#torrent-info
关于python - libtorrent python 绑定(bind)中的 torrent_info() 和磁力链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10251305/