加入收藏 | 设为首页 | 会员中心 | 我要投稿 驾考网 (https://www.jiakaowang.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 教程 > 正文

创建 BTB种子并获取 BTB种子信息

发布时间:2023-05-16 08:37:03 所属栏目:教程 来源:
导读:最近研究了一下linux BT服务器环境的搭建,需要在linux下制作BT种子并获取BT种子信息

安装:

[root@localhost src]# tar zxf mktorrent-1.0.tar.gz

[root@localhost src]# cd mktorrent-1.0

[root@local
最近研究了一下linux BT服务器环境的搭建,需要在linux下制作BT种子并获取BT种子信息

安装:

[root@localhost src]# tar zxf mktorrent-1.0.tar.gz

[root@localhost src]# cd mktorrent-1.0

[root@localhost mktorrent-1.0]# make

[root@localhost mktorrent-1.0]# make install

[root@localhost ~]# which mktorrent

/usr/local/bin/mktorrent

安装:

#tar -zxf bencode-1.0.tar.gz

#cd bencode-1.0.tar.gz

#python setup.py install

制作和验证的python脚本如下:

#!/usr/bin/env python # -*- coding: utf-8 -*- import os,re,time,sys import hashlib,bencode file_name = 'bt_test.exe' bt_source = '/data/updir/%s' % file_name bt_name = '/data/source/%s.torrent' % file_name if os.path.exists(bt_name): os.remove(bt_name) if os.path.exists(bt_source): conm = "/usr/local/bin/mktorrent -v -p -l 18 -a  -a  -o %s %s" % (bt_name,bt_source) res = os.popen(conm).readlines()[-1].strip() if 'done' in res: bt_path = {} bt_file = open(bt_name,'rb') bt_info = bencode.bdecode(bt_file.read()).get('info') bt_info_hash_hex = hashlib.sha1(bencode.bencode(bt_info)).hexdigest() if os.path.isdir(bt_source): bt_file_size = 0 for length in bt_info.get('files'): bt_file_size = bt_file_size + int(length['length']) bt_path['/'.join(length['path'])] = length['length'] else: bt_file_size = bt_info.get('length') bt_file_name = bt_info.get('name') bt_path[bt_file_name]=bt_file_size bt_file.close() print bt_path print "Create torrent success" else: print "Create torrent Error" sys.exit() else: print "This source not find" sys.exit()
file_name为做种的文件或目录名字。

(编辑:驾考网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章