失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > linux平台使用Python制作BT种子并获取BT种子信息办法

linux平台使用Python制作BT种子并获取BT种子信息办法

时间:2021-01-28 16:36:48

相关推荐

linux平台使用Python制作BT种子并获取BT种子信息办法

后端开发|Python教程

linux Python BT

后端开发-Python教程

永恒之蓝 源码,vscode 纯黑,ubuntu网口开启,两tomcat变慢,sqlite 命令和语句,大漠插件代码,uikit前端框架教程学习,爬虫软件案件杨帆,php

,淘宝seo什么意思,网站qq客服悬浮代码安装,简洁网页导航,帝国仿畅言模板,jquery 页面关闭,学生管理系统框架,php网盘程序lzw最近研究了一下linux BT服务器环境的搭建,需要在linux下制作BT种子并获取BT种子信息,整理了一下这个过程:

手 仙境ol源码,远程Ubuntu无法全屏,爬虫 合法性,php sass,李贝seolzw

制作BT种子软件本站下载地址。

微酒店 网站源码,vscode里快捷换行,开启ubuntu桌面,tomcat 口令文件,sqlite取表创建时间,dzapp分类信息插件,兼容性好的前端ui框架,网络爬虫的基本操作流程,php hr,合肥seo公司报价,php课程网站源码,手机网页 图片大小,51ec模板转码专用工具lzw

安装:

[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

需要python的bencode模块来获取BT种子信息,下载地址: /packages/source/b/bencode/bencode-1.0.tar.gz。

安装:

#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, sysimport hashlib, bencodefile_name = t_test.exet_source = /data/updir/%s % file_namebt_name = /data/source/%s.torrent % file_nameif 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 /announce -a /announce -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, b) 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 = 0for 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( ame)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为做种的文件或目录名字。

更多linux平台使用Python制作BT种子并获取BT种子信息的方法相关文章请关注PHP中文网!

如果觉得《linux平台使用Python制作BT种子并获取BT种子信息办法》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。