BTMetafile

A while ago i started with BTMetafile as a php class that can create BitTorrent metafiles. As of now, it can generate the metafile structure and bencodes single files or directories properly (bencoding is done through a separate BTBencode class). Yet it lacks a class for  decoding.
Class BTMetafile can be obtained from http://svn.var.cc/svn/phpbtmc/btmetafile.php (user anonymous, no password)

Usage:

$encoder = new BTBencode();
$opts = array('encoder'     => $encoder,
              'announceurl' => 'http://var.cc:6969/announce');

$m = new BTMetafile($opts);
$m->makeMetafile('/tmp/test.mp3');
$m->saveMetafile('/tmp/test.mp3.torrent');

(4)
Permalink
Posted in:

Comments

moron @ 14.07.2005 02:46 CEST
Thanks very much for posting this. I haven't had a chance to test it yet but if it works as advertised then you just made my life a lot easier trying to add some torrent functionality to a community file archive I look after.

If it all works out I'll drop a note when it is in place so you can check it out.

Cheers

http://industrial.org
silvan @ 14.07.2005 22:44 CEST
Hi
Please feel free to also drop a note in case it doesn't works out :)
I tested it with the original python bt client and Azureus.

moron @ 16.07.2005 03:07 CEST
Howdy. I found a bug which I have corrected. The problem is that dictionaries are supposed to be sorted which they were't being. The problem is in the function BTMetafil::makeMetafile() - essentially you need to do some key sorts on the arrays. Here's the changed lines:

$info = $this->makeinfo($file);
ksort($info);
$this->metainfostruct['info'] = $info;
ksort($this->metainfostruct);

Before sorting I would get errors from the Python client. After sorting all is happy.

Cheers!

http://industrial.org
http://ampfea.org
silvan @ 17.07.2005 02:03 CEST
Indeed - i recognized that i confused the getFileInfo() method so that the pieces key appeard first. Is fixed in svn and added the ksort() as well.

Thanks!
s
No new comments allowed (anymore) on this post.

LiveSearch

Blogroll

Relayed

Archive

Buttons

  • RSS 2.0 Feed
  • Latest comments
  • XHTML 1.0 compliant
  • Powered by Flux CMS
  • Powered by Popoon

Login


BXCMSNG Errors:
Notice[8] Undefined index: 0 in [BX_PROJECT_DIR]/inc/bx/plugins/blog/categories.php at line 59.