admin管理员组

文章数量:1551733

Python实现bt转磁链

参考前人资料主要两种方式

1,利用python的bencode模块

2,安装libtorrent模块

尝试过两种方法特记录

环境:Windows系统 python 3

bencode模块有很多,最早的一个不支持 python3,网上的实例代码就是使用2.7 所以 结果是不行。

选了一个bencoder.pyx 1.2.0 不知道为啥选这个

可以参考一下他的示例

pip 安装,上代码

from bencoder importbencode, bdecodeimporthashlibimportbase64

with open("加勒比海盗5:死无对证.2017.BD720P.X264.AAC.English&Mandarin.CHS-ENG.laziku.mp4.torrent", mode='rb',) as f :

torrent=bdecode(f.read())#print(bencode(torrent[b'info']))

#print(torrent)

#torrent = f.read()

digest= hashlib.sha1(bencode(torrent[b'info'])).digest()#torrent[b'info'] 里面包含了种子文件的关键信息 对这部分进行哈希处理

b32hash =base64.b32encode(digest)print

本文标签: 种子btPythonMagnet