Net::BitTorrent::Torrent::Generator - .torrent metadata generator
# Generate a single file .torrent to seed file.avi my $t1 = Net::BitTorrent::Torrent::Generator->new( path => 'file.avi' ); # Add everything in the current directory accept .torrent files my $t2 = Net::BitTorrent::Torrent::Generator->new( path => '../', path_skip => qr[.*torrent$] ); # 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;
TODO
Creating a new .torrent is simple. As is this API.
Creates a new generator object.
This constructor requires the following arguments:
path
See path.
This constructor also supports the following optional arguments:
announce
See announce.
announce_list
See announce_list.
path_skip
See path_skip.
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.
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->_set_piece_length
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 ] ) >.
$torrent->_set_announce_list( [ [url, url], [url] ] )
$torrent->_add_tier( [ url, url ] ) >.
See also BEP12.
This is an optional, free-form textual comment.
Returns the list of files contained in this torrent.
Returns the 160bit hex string used to identify this torrent as a Bit::Vector object.
160bit
This method generates and returns the metadata.
For raw data ready to write to disk, see raw_data.
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_path( $path ) to set this value later.
$torrent->_set_path( $path )
This is a regular expression. If pathpath( )"> is a directory, found files are checked against this regex. If they match, they're ignored when generating <metadata|/"$torrent->metadata( )">.
Use $torrent->_set_path_skip( qr[...] ) to set this value later and $torrent->_clear_path_skip( ) to clear it.
$torrent->_set_path_skip( qr[...] )
$torrent->_clear_path_skip( )
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.
2**18
A boolean value for cheap DRM behaviour.
Use $torrent->_set_private to set this on and $torrent->_unset_private to turn it back off.
$torrent->_set_private
$torrent->_unset_private
See also BEP27.
Generates metadata and returns it as a bencoded string. This is what you'd write to disk.
Returns the total size of all the files related to this torrent.
This class may be renamed. Suggestions welcome.
BEP03
Net::BitTorrent::File
Sanko Robinson <sanko@cpan.org> - http://sankorobinson.com/
CPAN ID: SANKO
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.
1 POD Error
The following errors were encountered while parsing the POD:
Unterminated C< ... > sequence
To install Net::BitTorrent, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::BitTorrent
CPAN shell
perl -MCPAN -e shell install Net::BitTorrent
For more information on module installation, please visit the detailed CPAN module installation guide.