Ed2k_link - module for creation and work with eD2K links
Version 20090427
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) { print "files " . $emule -> filename . " and " . $sources -> filename . " are the same\n"; } print Ed2k_link -> from_file('/somethere/cool_file.txt') -> link('hp');
Ed2k_link module for generation 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).
Can be called as class or instance method:
my $t = Ed2k_link -> from_file('file_1.txt') or die 'something wrong!'; $t -> from_file('file_2.txt') or die 'something wrong!';
Creates all fields of eD2K link including hash, AICH hashset, complete hashset.
In case of any error returns undef and object doesn't hold any link information.
Sets Reliable flag to true.
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 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.
Instance only method. Returns true if object was successfully created and holds all required fields;
&do_something if $t1 -> ok;
Instance only method. Returns string representation of link. Can have parameter with options:
h - include (if present) AICH hash (recommended) p - include (if present) complete hashset my $link1 = $t -> link; my $link_with_aich = $t -> link('h'); my $link_with_hashset = $t -> link('p'); my $iron_link = $t -> link('hp');
Instance method. Returns filename;
print $t -> filename;
Instance method. Returns escaped filename (as in link);
print $t -> escaped_filename;
Instance method. Returns filesize;
Instance method. Returns hash field from link;
Instance method. Returns true if object has complete hashset, false otherwise;
Instance method. Returns complete hashset if object has it. undef otherwise;
Instance method. Returns true if object has aich hash, false otherwise;
Instance method. Returns AICH hash if object has it. undef otherwise;
Instance method. Returns true if object is reliable, false otherwise;
Instance method. Sets Reliable flag for object. Use it very carefully, or you could end up with fake links, that lead nowhere and you couldn't 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 using of this method is appropriated;
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);
Valery Kalesnik, <valkoles at gmail.com>
<valkoles at gmail.com>
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.
bug-ed2k_link at rt.cpan.org
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
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Ed2k_link
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Ed2k_link
CPAN Ratings
http://cpanratings.perl.org/d/Ed2k_link
Search CPAN
http://search.cpan.org/dist/Ed2k_link/
Copyright 2009 Valery Kalesnik, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Ed2k_link, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Ed2k_link
CPAN shell
perl -MCPAN -e shell install Ed2k_link
For more information on module installation, please visit the detailed CPAN module installation guide.