2017-05-23 11 views
1

나는 토런트를 libtorrent를 사용하여 자석으로 변환하려고합니다.Libtorrent 토런트 ->

내가 파이썬에서 당신이

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()); 

그러나 결과가 아닌 적절한 문자열에 다음과 같은 노력했습니다 사용할 수 있습니다 읽었습니다 (이진)와 수 없습니다 결과를 사용하십시오.

누군가 내가 토런트의 해시를 인쇄 할 수있는 것으로 변환하는 방법을 알고 있습니까?

고마워요.

답변

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);