【问题标题】:torrent_info() and magnet links in libtorrent python bindingslibtorrent python 绑定中的 torrent_info() 和磁力链接
【发布时间】:2012-04-20 18:10:09
【问题描述】:

我正在搜索在 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”?

【问题讨论】:

    标签: python magnet-uri libtorrent


    【解决方案1】:

    添加磁力链接会为您提供一个 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

    【讨论】:

    猜你喜欢
    • 2021-07-18
    • 1970-01-01
    • 2018-10-22
    • 2018-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-01
    相关资源
    最近更新 更多