简体   繁体   English

Libtorrent洪流 - >磁铁

[英]Libtorrent torrent->magnet

I'm trying to convert some torrents into magnets using libtorrent. 我正试图用libtorrent将一些种子变成磁铁。

I've read that in python you can use 我已经在python中读到了你可以使用的内容

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

I've tried the following on C++ 我在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());

But the result is not a proper string (is binary) and cannot use the result. 但结果不是一个正确的字符串(是二进制),不能使用结果。

Someone knows how to convert the hash of a torrent to something I can print? 有人知道如何将洪流的哈希转换为我可以打印的东西吗?

Thanks a lot. 非常感谢。

You can use make_magnet_uri declared in "libtorrent/magnet_uri.hpp" . 您可以使用make_magnet_uri在宣布"libtorrent/magnet_uri.hpp"

Here's a sample code to convert torrent file to magnet uri: 这是一个将torrent文件转换为magnet uri的示例代码:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM