【问题标题】:Libtorrent torrent->magnetLibtorrent torrent->磁铁
【发布时间】:2017-05-23 11:52:23
【问题描述】:

我正在尝试使用 libtorrent 将一些种子文件转换为磁铁。

我读过你可以在 python 中使用

 info = libtorrent.torrent_info(sys.argv[1])
 print "magnet:?xt=urn:btih:%s&dn=%s" % (info.info_hash(), info.name())

我在 C++ 上尝试过以下方法

 torrent_info ti(current_file.c_str(), ec);
 printf("magnet:?xt=urn:btih:%s&dn=%s\n", ti.info_hash().to_string().c_str(), ti.name().c_str());

但结果不是正确的字符串(是二进制),不能使用结果。

有人知道如何将种子的哈希值转换为我可以打印的东西吗?

非常感谢。

【问题讨论】:

    标签: c++ torrent libtorrent


    【解决方案1】:

    您可以使用在"libtorrent/magnet_uri.hpp" 中声明的make_magnet_uri

    这是一个将 torrent 文件转换为磁铁 uri 的示例代码:

    error_code ec;
    torrent_info ti("filename", ec);
    std::string magnet_uri = make_magnet_uri(ti);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-02
      • 2017-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多