我正在尝试使用libtorrent将torrent转换为磁铁。
我在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());但结果不是正确的字符串(二进制),不能使用结果。
有人知道如何将torrent的散列转换成我可以打印的东西吗?
非常感谢。
发布于 2018-01-05 17:23:06
您可以使用在"libtorrent/magnet_uri.hpp"中声明的make_magnet_uri。
以下是将torrent文件转换为magnet uri的示例代码:
error_code ec;
torrent_info ti("filename", ec);
std::string magnet_uri = make_magnet_uri(ti);https://stackoverflow.com/questions/44134078
复制相似问题