NAME
Ed2k_link - module for creating eD2K links and working with them.
VERSION
version 20160412
SYNOPSIS
use Ed2k_link ();
print Ed2k_link -> from_file( 'c:\\temp\\new_movie.mkv' ) -> link( 'h' ) . "\n";
my $emule = Ed2k_link -> from_file( 'eMule0.49c.zip' ) or die 'something wrong with file!');
my $sources = Ed2k_link -> from_link( 'ed2k://|file|eMule0.49c.zip|2868871|0F88EEFA9D8AD3F43DABAC9982D2450C|/' ) or die 'incorrect link!';
$sources -> from_link( 'ed2k://|file|eMule0.49c-Sources.zip|5770302|195B6D8286BF184C3CC0665148D746CF|/' ) or die 'incorrect link!';
print $emule -> link( 'h' ) if $emule -> filesize <= 10 * 1024 * 1024, "\n";
if ( Ed2k_link -> equal( $emule, $sources ) {
printf "files %s and %s are equal\n";
$emule -> filename,
$sources -> filename;
}
print Ed2k_link -> from_file( '/somethere/cool_file.txt' ) -> link('hp');
DESCRIPTION
Ed2k_link module for creating eD2K links from files with correct hash, AICH hash and complete hashset fields. Also it can work with already created links (e. g. from textfile).
CLASS METHODS
from_file
Can be called as class or instance method:
my $t = Ed2k_link -> from_file( 'file_1.txt' ) or die 'error!';
$t -> from_file( 'file_2.txt' ) or die 'error!';
Creates all fields of eD2K link including hash, AICH hashset, complete hashset.
Filename should be a character string (as opposed to octet string). In case of any error returns undef and object doesn't hold any link information.
Sets Reliable flag to true.
from_link
Can be called as class or object method:
my $tl = Ed2k_link -> from_link( 'ed2k://|file|eMule0.49c.zip|2868871|0F88EEFA9D8AD3F43DABAC9982D2450C|/' )
or die 'incorrect link!';
$t1 = from_link( 'ed2k://|file|eMule0.49c-Sources.zip|5770302|195B6D8286BF184C3CC0665148D746CF|/' )
or die 'incorrect link!';
Takes mandatory (filename/size/hash) and optional (AICH hash, complete hashset) fields from the link. Checks some correctness of fields (acceptable symbols, length, ...). If link in parameter has complete hashset, checks compliance between hash and complete hashset.
In case of any incorrectness returns undef and object doesn't hold any link information.
If link in parameter has AICH and/or complete hashset, sets Reliable flag to false. Otherwise it's true.
ok
Instance only method. Returns true if object was successfully created and holds all required fields;
&do_something() if $t1 -> ok;
filename
Instance method. Returns filename as character string:
print $t -> filename;
escaped_filename
Instance method. Returns escaped filename (as in link);
print $t -> escaped_filename;
filesize
Instance method. Returns filesize;
hash
Instance method. Returns hash field from link;
has_complete_hashset
Instance method. Returns true if object has complete hashset, false otherwise;
complete_hashset
Instance method. Returns complete hashset if object has it. undef otherwise;
has_aich
Instance method. Returns true if object has aich hash, false otherwise;
aich
Instance method. Returns AICH hash if object has it. undef otherwise;
link
Instance only method. Returns string representation of link. Can have parameter with options:
h - include AICH hash if available. Recommended.
p - include complete hashset if available.
my $link1 = $t -> link;
my $link_with_aich = $t -> link( 'h' );
my $link_with_hashset = $t -> link( 'p' );
my $iron_link = $t -> link( 'hp' );
is_reliable
Instance method. Returns true if object is reliable, false otherwise;
set_reliable
Instance method. Sets Reliable flag for object. Use it very carefully, or you could end up with fake link that doesn't reference any file and you won't be able to download anything with them.
Carefully means: you got string link from someone, who you trust. Or you previously created it from file by yourself and saved somethere and now you're reading those links from file of database. Such usage of this method is appropriated;
equal
Class only method. Compares two Ed2k_link objects by complex rules. Returns true if they point to the same file. Could fill some fields of one object with other's objects fields. Also can set Reliable flag.
print "hey! they are the same!" if Ed2k_link -> equal($t1, $t2);
AUTHOR
Valery Kalesnik, <valkoles at gmail.com>
BUGS
Please report any bugs or feature requests to bug-ed2k_link at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Ed2k_link. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Ed2k_link
You can also look for information at:
RT: CPAN's request tracker
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN