python - libtorrent python 绑定(bind)中的 torrent_info() 和磁力链接

标签 python magnet-uri libtorrent

我正在寻找如何在 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/

相关文章:

python - 使用shell脚本调用多个ROS启动文件

python - 在选择后从列表中删除项目的随机生成器

c++ - libtorrent-rasterbar 无法使用磁力链接下载元数据

javascript - 检查浏览器是否安装了 torrent 客户端

c++ - Libtorrent python SSL 绑定(bind)

python - 使用 with - python 打开超过 1 个文件

python - 检测日志文件轮换(同时观察日志文件进行修改)

.net - MonoTorrent - Torrent 文件的磁力链​​接

python - 使用 Python libtorrent 创建守护进程以获取 100k+ 种子的元数据

python - 如何使用 libtorrent for python 获取 info_hash