bt磁力种子(怎么把bt种子转换成磁力链接)
2025-03-21 06:25 - 立有生活网
我想把我网盘里的资源做BT种子或者磁力链接,这个那个软件可以?
2、代码如下:用BT(BitComet),文件选项里面有一个制作种子,然后选中你想要上传的东西,他会自动生成一个BT文件,然后找一个你想上传的网站,把生成的文件传上去,在你的BitComet里面开启任务,就可以了。
bt磁力种子(怎么把bt种子转换成磁力链接)
bt磁力种子(怎么把bt种子转换成磁力链接)
def magnet2torrent(magnet, output_name=None):
如何使用python实现bt种子和磁力链接的相互转换
if __name__ == "__main__":相应的将BT种子转换为磁力链代码为:
import bencode, hashlib, base64, lib
torrent = open('ubuntu-12.04.2-server-amd64.iso.torrent', 'rb').read()
metadata = bencode.bdecode(torrent)
hashcontents = bencode.bencode(metadata[''])
digest = hashlib.sha1(hashcontents).digest(1、需要先安装python-libtorrent包 ,在ubuntu环境下,可以通过以下指令完成安装:)
b32hash = base64.b32encode(digest)
params = {'xt': 'urn:btih:%s' % b32hash,
'dn': metadata['']['name'],
'tr': metadata['announce'],
'xl': metadata['']['length']}
paramstr = lib.encode(params)
magneturi = 'magnet:?%s' % paramstr
print magneturi
还有另外一个效率相对较高,而且更方便的方案是安装libtorrent,在ubuntu只需要apt-get install python-libtorrent即可对应转换磁力链的代码为:
import libtorrent as bt
= bt.torrent_('test.torrent')
print "magnet:?xt=urn:btih:%s&dn=%s" % (._hash(), .name())
转换磁力链接为bt种子文件
下面来看一个反过程,将磁力链转化为种子文件。
# sudo apt-get install python-libtorrent
#!/usr/bin/env python
import shutil
import tempfile
import os.path as pt
import sys
import libtorrent as lt
from time import sleep
if output_name and
not pt.isdir(output_name) and
not pt.isdir(pt.dirname(pt.abspath(output_name))):
print("Invalid output folder: " + pt.dirname(pt.abspath(output_name)))
print("")
sys.exit(0)
tempdir = tempfile.mkdtemp()
ses = lt.session()
params = {
'se_path': tempdir,
'duplicate_is_error': True,
'storage_mode': lt.storage_mode_t(2),
'paused': False,
'auto_mad': True,
'duplicate_is_error': True
}handle = lt.add_magnet_uri(ses, magnet, params)
print("Downloading Metadata (this may take a while)")
while (not handle.has_metadata()):
try:
sleep(1)
except KeyboardInterrupt:
print("Aborting...")
ses.pause()
print("Cleanup dir " + tempdir)
shutil.rmtree(tempdir)
sys.exit(0)
ses.pause()
print("Done")
tor = handle.get_torrent_()
torfile = lt.create_torrent(tor)
output = pt.abspath(tor.name() + ".torrent")
if output_name:
if pt.isdir(output_name):
output = pt.abspath(pt.join(
output_name, tor.name() + ".torrent"))
elif pt.isdir(pt.dirname(pt.abspath(output_name))):
output = pt.abspath(output_name)
print("Sing torrent file here : " + output + " ...")
torcontent = lt.bencode(torfile.generate())
f = open(output, "wb")
f.write(lt.bencode(torfile.generate()))
f.close()
print("Sed! Cleaning up dir: " + tempdir)
ses.remove_torrent(handle)
shutil.rmtree(tempdir)
return output
def showHelp():
print("")
print("USAGE: " + pt.basename(sys.argv[0]) + " MAGNET [OUTPUT]")
print(" MAGNETt- the magnet ")
print(" OUTPUTt- the output torrent file name")
print("")
def main():
if len(sys.argv) < 2:
showHelp()
sys.exit(0)
magnet = sys.argv[1]
output_name = None
if len(sys.argv) >= 3:
output_name = sys.argv[2]
magnet2torrent(magnet, output_name)
main()
3、用法如下
# python Magnet_To_Torrent2.py
攸县养殖蚯蚓基地地址 湖南省内哪里有养蚯蚓

光山县城买蚯蚓的地方在哪儿 非常感谢您的提问。洛阳是河南省下辖的一个美丽的城市,目前还没有亚太饲料虫养殖基地在这里,但洛阳市有多家饲料养殖企业,其中很多都是规模较大的企业,能···
二进制转换器 数字转二进制转换器

大家好,今日小柳来为大家解答以上的问题。二进制转换器,数字转二进制转换器很多人还不知道,现在让我们一起来看看吧! 二进制转换器 数字转二进制转换器 二进制转换器 数字转二进制转换···
家里养殖水培花卉好吗视频 家里养殖水培花卉

源源给大家谈谈家里养殖水培花卉好吗视频,以及家里养殖水培花卉好吗视频教学应用的知识点,希望对你所遇到的问题有所帮助。 家里养殖水培花卉好吗视频 家里养殖水培花卉好吗视频教学 家···