BT种子文件格式[ ]

BT种子文件格式

BT种子文件使用了一种叫bencoding的编码方法来保存数据。
bencoding现有四种类型的数据:srings(字符串),integers(整数),lists(列表),dictionaries(字典)
编码规则如下:
strings(字符串)编码为:<字符串长度>:<字符串>
例如: 4:test 表示为字符串"test"
4:例子 表示为字符串“例子”
字符串长度单位为字节
没开始或结束标记

integers(整数)编码为:i<整数>e
开始标记i,结束标记为e
例如: i1234e 表示为整数1234
i-1234e 表示为整数-1234
整数没有大小限制
i0e 表示为整数0
i-0e 为非法
以0开头的为非法如: i01234e 为非法

lists(列表)编码为:l<bencoding编码类型>e
开始标记为l,结束标记为e
列表里可以包含任何bencoding编码类型,包括整数,字符串,列表,字典。
例如: l4:test5abcdee 表示为二个字符串["test","abcde"]

dictionaries(字典)编码为d<bencoding字符串><bencoding编码类型>e
开始标记为d,结束标记为e
关键字必须为bencoding字符串
值可以为任何bencoding编码类型
例如: d3:agei20ee 表示为{ "age"=20 }
d4:path3:C:/8:filename8:test.txte 表示为{ "path"="C:/","filename"="test.txt" }

具体文件结构如下:
全部内容必须都为bencoding编码类型。
整个文件为一个字典结构,包含如下关键字
announce:tracker服务器的URL(字符串)
announce-list(可选):备用tracker服务器列表(列表)
creation date(可选):种子创建的时间,Unix标准时间格式,从1970 1月1日 00:00:00到创建时间的秒数(整数)
comment(可选):备注(字符串)
created by(可选):创建人或创建程序的信息(字符串)
info:一个字典结构,包含文件的主要信息,为分二种情况:单文件结构或多文件结构
单文件结构如下:
         length:文件长度,单位字节(整数)
         md5sum(可选):长32个字符的文件的MD5校验和,BT不使用这个值,只是为了兼容一些程序所保留!(字符串)
         name:文件名(字符串)
         piece length:每个块的大小,单位字节(整数)
         pieces:每个块的20个字节的SHA1 Hash的值(二进制格式)
多文件结构如下:
         files:一个字典结构
                length:文件长度,单位字节(整数)
                md5sum(可选):同单文件结构中相同
                path:文件的路径和名字,是一个列表结构,如/test/test.txt 列表为l4:test8test.txte
         name:最上层的目录名字(字符串)
         piece length:同单文件结构中相同
         pieces:同单文件结构中相同
实例:
用记事本打开一个.torrent可以看来类似如下内容
d8:announce37:http://bt4.eastgame.net:6969/announce13:announce-listll37:http://bt4.eastgame.net:6969/announceee8:codepagei936e13:creation datei1104368830e4:infod5:filesld6:lengthi103884044e4:pathl50:Band.of.Brothers.兄弟连.EP01.HDTV.720p.Recover.rareed6:lengthi1211e4:pathl42:Band.of.Brothers.兄弟连.EP01.HDTV.720p.nfoeed6:lengthi102400000e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part01.rareed6:lengthi102400000e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part02.rareed6:lengthi102400000e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part03.rareed6:lengthi102400000e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part04.rareed6:lengthi102400000e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part05.rareed6:lengthi102400000e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part06.rareed6:lengthi102400000e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part07.rareed6:lengthi102400000e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part08.rareed6:lengthi102400000e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part09.rareed6:lengthi102400000e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part10.rareed6:lengthi102400000e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part11.rareed6:lengthi102400000e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part12.rareed6:lengthi102400000e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part13.rareed6:lengthi102400000e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part14.rareed6:lengthi102400000e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part15.rareed6:lengthi102400000e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part16.rareed6:lengthi102400000e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part17.rareed6:lengthi102400000e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part18.rareed6:lengthi102400000e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part19.rareed6:lengthi102400000e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part20.rareed6:lengthi102400000e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part21.rareed6:lengthi102400000e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part22.rareed6:lengthi102400000e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part23.rareed6:lengthi102400000e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part24.rareed6:lengthi102400000e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part25.rareed6:lengthi102400000e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part26.rareed6:lengthi19577056e4:pathl49:Band.of.Brothers.兄弟连.EP01.HDTV.720p.part27.rareed6:lengthi50169e4:pathl42:Band.of.Brothers.兄弟连.EP01.HDTV.720p.srteee4:name38:Band.of.Brothers.兄弟连.EP01.HDTV.720p12:piece lengthi524288e6:pieces106280:|K薒?穆拥2挥
菚8险%禸胒帻佚EX跖Sg*敥舑HPR?/p ▇r銢e级C阡团鮼编%

容易看出
announce=http://bt4.eastgame.net:6969/announce
creation date=1104368830秒
文件名=Band.of.Brothers.兄弟连.EP01.HDTV.720p
文件块=106280
文件块大小=524288字节

PS: e级C阡团鮼编%


http://goohome.kmip.net/blog.php
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章