admin管理员组文章数量:1026989
经常下载电影的朋友肯定对BT种子不陌生,但是BT种子文件相对磁力链来说存储不方便,而且在网站上存放BT文件容易引起版权纠纷,而磁力链相对来说则风险小一些。
将BT种子转换为占用空间更小,分享更方便的磁力链还是有挺大好处的。
今天咱们来看下如何将种子转换成磁力链接,方案是:利用python的bencode模块,用起来比较简单
首先要安装这个模块,安装命令:
pip install bencode
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
最后,推荐一个BT搜索引擎 www.sobt.vip,大部分的bt种子都能找到
经常下载电影的朋友肯定对BT种子不陌生,但是BT种子文件相对磁力链来说存储不方便,而且在网站上存放BT文件容易引起版权纠纷,而磁力链相对来说则风险小一些。
将BT种子转换为占用空间更小,分享更方便的磁力链还是有挺大好处的。
今天咱们来看下如何将种子转换成磁力链接,方案是:利用python的bencode模块,用起来比较简单
首先要安装这个模块,安装命令:
pip install bencode
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
最后,推荐一个BT搜索引擎 www.sobt.vip,大部分的bt种子都能找到
版权声明:本文标题:使用Python把BT种子转化为磁力链接 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/jiaocheng/1740361852a1756633.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论