请注意python版本
bt2url.py #! /usr/local/bin/python # @desc python通过BT种子生成磁力链接 # @date 2015/11/10 # @author pythontab测试数据 import bencode import sys import hashlib import base64 import urllib #获取参数 torrentName = sys.argv[1] #读取种子文件 torrent = open(torrentName, 'rb').read() #计算meta数据 metadata = bencode.bdecode(torrent) hashcontents = bencode.bencode(metadata['info']) digest = hashlib.sha1(hashcontents).digest() b32hash = base64.b32encode(digest) #打印 print 'magnet:?xt=urn:btih:%s' % b32hash
如何使用?
命令:
python bt2url.py test.torrent
结果 :
magnet:?xt=urn:btih:MWXFHXOGE2UMR7WBFZYEJPM3LF2VIHNH
查看更多关于实战Python实现BT种子转化为磁力链接的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did83020