Valery Kalesnik > Ed2k_link > Ed2k_link

Download:
Ed2k_link-20090428.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 20090428   Source  

NAME ^

Ed2k_link - module for creation and work with eD2K links

VERSION ^

Version 20090428

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) {
    print "files " . $emule -> filename . " and " . $sources -> filename . " are the same\n";
  }

  print Ed2k_link -> from_file('/somethere/cool_file.txt') -> link('hp');

DESCRIPTION ^

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).

CLASS METHODS ^

from_file

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.

from_link

Can be called as class or instance 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 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;

link

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');

filename

Instance method. Returns filename;

  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;

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 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;

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:

COPYRIGHT & LICENSE ^

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.

syntax highlighting: