Here's the code (in perl) and Here's an example of the output
I was writing a CGI script that kept making calls to someone else's python script to decode .torrent files, and then it was parsing the output of the python script for the required information. I figured I'd write my own... it should be faster.
Anyway, the decoder is above. If you want to run it, here are directions:
You must have perl (download it here for windows) installed.
Download the file at the top of this page.
Rename the file from 'btdecode.txt' to 'btdecode.pl'
open a command prompt, go to the directory where you saved the script, and type "perl btdecode.pl somefile.torrent" where "somefile.torrent" is the path to any .torrent file.
I thought it was interesting the way the files are put together, if anyone else is interested, this will give you a hierarchical (probably spelled wrong) view of how they're constructed of dictionaries, lists, strings, and integers.
I was writing a CGI script that kept making calls to someone else's python script to decode .torrent files, and then it was parsing the output of the python script for the required information. I figured I'd write my own... it should be faster.
Anyway, the decoder is above. If you want to run it, here are directions:
You must have perl (download it here for windows) installed.
Download the file at the top of this page.
Rename the file from 'btdecode.txt' to 'btdecode.pl'
open a command prompt, go to the directory where you saved the script, and type "perl btdecode.pl somefile.torrent" where "somefile.torrent" is the path to any .torrent file.
I thought it was interesting the way the files are put together, if anyone else is interested, this will give you a hierarchical (probably spelled wrong) view of how they're constructed of dictionaries, lists, strings, and integers.