首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Libtorrent torrent->磁铁

Libtorrent torrent->磁铁
EN

Stack Overflow用户
提问于 2017-05-23 19:52:23
回答 1查看 559关注 0票数 1

我正在尝试使用libtorrent将torrent转换为磁铁。

我在python中读到过,你可以使用

代码语言:javascript
复制
 info = libtorrent.torrent_info(sys.argv[1])
 print "magnet:?xt=urn:btih:%s&dn=%s" % (info.info_hash(), info.name())

我已经在C++上尝试了以下内容

代码语言:javascript
复制
 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());

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

有人知道如何将torrent的散列转换成我可以打印的东西吗?

非常感谢。

EN

回答 1

Stack Overflow用户

发布于 2018-01-05 17:23:06

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

以下是将torrent文件转换为magnet uri的示例代码:

代码语言:javascript
复制
error_code ec;
torrent_info ti("filename", ec);
std::string magnet_uri = make_magnet_uri(ti);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44134078

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档