libtorrent python绑定中的torrent_info()和磁力链接 [英] torrent_info() and magnet links in libtorrent python bindings

查看:126
本文介绍了libtorrent python绑定中的torrent_info()和磁力链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在搜索如何在libtorrent中使用磁链时在torrent_info()函数中传递参数. 特别是我的目标是分析同伴和碎片.通过使用.torrent文件,很明显,该过程可以在此站点中抛出其他给定的范例:

I was searching how to pass an argument in torrent_info() function during the use of magnet links in libtorrent. Especially my target is to analyze peers and pieces. With the use of .torrent file the process is obvious throw other given paradigms in this site:

e = lt.bdecode(open("torrent.torrent", 'rb').read())
info = lt.torrent_info(e)

但是磁链会发生什么?

But what happens with the magnet links?

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进程的"e",以便能够正确使用torrent_info函数?

Which variable is equivalent to "e" of the .torrent process in magnet links case in order to be able to use torrent_info function properly?

推荐答案

添加磁力链接会给您一个洪流句柄,您可以从中获取洪流信息(一旦获取了元数据-否则将抛出该异常)

Adding a magnet link gives you a torrent handle, from which you will be able to get torrent infos (once the metadata has been fetched - it will throw otherwise).

不同于torrent文件(元数据已经在此处),磁力链接要求将元数据作为启动器从网络中检索,这可能需要一些时间.

Unlike torrent files, where the metadata is already here, magnet links require the metadata to be retrieved from the network as a starter, and that can take some time.

我更习惯于C ++库,但是-让它在最肮脏的地方进行演示,您可以执行以下操作:

I'm more used to the C++ library, but well - to have it demo at the dirtiest, you can do something in the line of:

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

... then, you can read all about it here ;) http://www.rasterbar.com/products/libtorrent/manual.html#torrent-info

这篇关于libtorrent python绑定中的torrent_info()和磁力链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆