Looking Into BitTorrent


Posted

in


Roger got me interested in BitTorrent this evening.  I was curious about the anatomy of a .torrent file, so I dug into bencode.py from the BitTorrent source distro.  It’s all in python (with wxPython for GUI), so I felt pretty comefortable.  I put together a tiny little script that pretty much uses bencode to grab a .torrent file, analyze it, and print it to the screen:

C:/py/torrent>python btinfo.py http://www.turok.info/bt/a.u.s.a.s01e06.walters.first.law.suit-ftv.torrent
Connecting to http://www.turok.info/bt/a.u.s.a.s01e06.walters.first.law.suit-ftv.torrent
Announce: http://tracker.powerpuffgrrlz.com:9696/announce
Name: a.u.s.a.s01e06.walters.first.law.suit-ftv
Piece length: 262144
File Info:
 Path: ['AUSA-1x06_-_get_the_latest_episodes.txt']
 Length: 342
 Path: ['a.u.s.a.s01e06.walters.first.law.suit-ftv.mpg']
 Length: 220427748

Here’s btinfo.py, released under the MIT license, which is the same license as BitTorrent itself.  It requires bencode.py from the source distro to be in the same directory as btinfo.  It’s a few dozen lines of code and is dumb simple to use:

Usage: C:/py/torrentbtinfo.py url.
Example: C:/py/torrent/btinfo.py http://url.com/file.torrent

I’m planning to play around with BitTorrent a little more in the future, stay tuned.