2017-05-23 6 views
1

私はlibtorrentを使用していくつかのトレントをマグネットに変換しようとしています。Libtorrentトレント - >

私はpythonで私は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()); 

に次のことを試してみたが、結果は適切な文字列ではありません(バイナリ)とすることはできません

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

を使用することができることを読みました結果を使用します。

誰かがトレントのハッシュを印刷できるものに変換する方法を知っていますか?

ありがとうございます。

答えて

0

これはちょっと古い質問ですが、"libtorrent/magnet_uri.hpp"で宣言されたmake_magnet_uriを使用できます。

ここマグネットURIにトレントファイルを変換するためのサンプルコードです:

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