python解析torrent文件库:pytorrent

来源:互联网 发布:ipadpro下载软件流程 编辑:程序博客网 时间:2024/06/05 03:07

pytorrent是一个非常小巧的用来解析解析torrent文件python库。核心代码不足150行,却能够完备地解析torrent文件,并支持导出修改后的torrent文件。

使用演示:

import pytorrentt=pytorrent.Torrent()t.load("test.torrent")  #your torrent fileprint t.data["info"]["name"].decode("utf-8")files=t.data["info"]["files"]for item in files:    print item["path"][0].decode("utf-8")t.data["info"]["name"]="my_name" #change info.t.dump("dump.torrent")  #the new torrent file

该库把torrent文件结构映射到python的dict,list,integer,string四种类型,直接操作这四种数据就能读取和修改torrent文件的一切信息。

项目地址

1 0
原创粉丝点击