Sanko Robinson > Net-BitTorrent-0.074000_012 > Net::BitTorrent::Torrent::Generator

Download:
Net-BitTorrent-0.074000_012.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.074000_012   Source  

NAME ^

Net::BitTorrent::Torrent::Generator - .torrent metadata generator

Synopsis ^

    # Generate a single file .torrent to seed file.avi
    my $t1 = Net::BitTorrent::Torrent::Generator->new( files => 'file.avi' );

    # Add everything in the current directory accept .torrent files
    my $t2 = Net::BitTorrent::Torrent::Generator->new(
        files      => '../'
    );

    # Now, let's write the metadata to disk
    print 'Saving ' .  $t2->info_hash->to_Hex . '...';
    open my($torrent), '>', 'test.torrent' || die 'FAIL!';
    syswrite $torrent, $t2->raw_data;
    close $torrent;

Description ^

TODO

Methods ^

Creating a new .torrent is simple. As is this API.

my $torrent = Net::BitTorrent::Torrent::Generator->new( files => ..., [ ... ] )

Creates a new generator object.

This constructor requires the following arguments:

files

See files.

This constructor also supports the following optional arguments:

announce

See announce.

announce_list

See announce_list.

comment

See comment.

merge

This is an advanced argument containing a hashref which will be merged with the final metadata when generated.

Don't use this.

piece_length

See "$torrent->piece_length( )" in piece_length.

private

See private.

$torrent->announce( )

The announce URL of the tracker. With the advent and current popularity of DHT, PEX, and other alternate means of learning about peers, this value may be considered optional.

Use $torrent->_set_piece_length to set this value.

$torrent->announce_list( )

Optional list of URLs.

Use $torrent->_set_announce_list( [ [url, url], [url] ] ) to set this value. To add a single tier, use $torrent->_add_tier( [ url, url ] ) >.

See also BEP12.

$torrent->comment( )

This is an optional, free-form textual comment.

$torrent->files( )

Returns the list of files contained in this torrent.

$torrent->info_hash( )

Returns the 160bit hex string used to identify this torrent as a Bit::Vector object.

$torrent->metadata( )

This method generates and returns the metadata.

For raw data ready to write to disk, see raw_data.

$torrent->files( )

This is a string contining either a directory or a single file.

If this is a directory, a multi-file torrent is generated.

Use $torrent->_set_files( $path ) to set this value later.

$torrent->piece_length( )

For the purposes of transfer, files are split into fixed-size pieces which are all the same length except for possibly the last one which may be truncated. piece_length is almost always a power of two, most commonly 2**18 (256KB). This is also our default value.

Use $torrent->_set_piece_length to set this value.

$torrent->private( )

A boolean value for cheap DRM behaviour.

Use $torrent->_set_private to set this on and $torrent->_unset_private to turn it back off.

See also BEP27.

$torrent->raw_data( )

Generates metadata and returns it as a bencoded string. This is what you'd write to disk.

$torrent->total_size( )

Returns the total size of all the files related to this torrent.

Notes ^

This class may be renamed. Suggestions welcome.

See Also ^

BEP03

Net::BitTorrent::File

TODO ^

Document optional .torrent name.

Author ^

Sanko Robinson <sanko@cpan.org> - http://sankorobinson.com/

CPAN ID: SANKO

License and Legal ^

Copyright (C) 2008-2010 by Sanko Robinson <sanko@cpan.org>

This program is free software; you can redistribute it and/or modify it under the terms of The Artistic License 2.0. See the LICENSE file included with this distribution or notes on the Artistic License 2.0 for clarification.

When separated from the distribution, all original POD documentation is covered by the Creative Commons Attribution-Share Alike 3.0 License. See the clarification of the CCA-SA3.0.

Neither this module nor the Author is affiliated with BitTorrent, Inc.

syntax highlighting: