python 获取BT种子文件信息

可以使用文中 http://www.jb51.net/article/74584.htm 这两种方法。

也可以这样用 http://blog.csdn.net/u014649204/article/details/41387081 //from btdht import Parser  关键语句

然而,貌似以下这种方法比较烦锁:

import bencode, hashlib, base64, urllib torrent = open('ubuntu-12.04.2-server-amd64.iso.torrent', 'rb').read() metadata = bencode.bdecode(torrent) hashcontents = bencode.bencode(metadata['info']) digest = hashlib.sha1(hashcontents).digest() b32hash = base64.b32encode(digest) params = {'xt': 'urn:btih:%s' % b32hash,       'dn': metadata['info']['name'],       'tr': metadata['announce'],       'xl': metadata['info']['length']} paramstr = urllib.urlencode(params) magneturi = 'magnet:?%s' % paramstr print magneturi 

 

怎么样在不下载的情况下,知道一个BT种子文件里面包含的下载文件的哈希值?

种子用的sha1 哈希算法,可以用winhex查看,我这几天也在研究bt,有兴趣一起交流啊。

我用的UE查看.. winhex不错哈。

全文:https://zhidao.baidu.com/question/517780541.html

posted @ 2016-12-13 13:28  stma  阅读(1310)  评论(0)    收藏  举报