]>
Commit | Line | Data |
---|---|---|
1 | package WWW::Offliberty; | |
2 | ||
3 | use 5.014; | |
4 | use strict; | |
5 | use warnings; | |
6 | use parent qw/Exporter/; | |
7 | our $VERSION = '0.001'; | |
8 | our @EXPORT_OK = qw/off/; | |
9 | ||
10 | use HTML::TreeBuilder; | |
11 | use LWP::UserAgent; | |
12 | ||
13 | my $ua = LWP::UserAgent->new; | |
14 | ||
15 | sub off{ | |
16 | my ($url, @params) = @_; | |
17 | my $content = $ua->post("http://offliberty.com/off.php", {track => $url, @params})->decoded_content; | |
18 | my $root = HTML::TreeBuilder->new_from_content($content); | |
19 | map { $_->attr('href') } $root->look_down(qw/_tag a class download/); | |
20 | } | |
21 | ||
22 | 1; | |
23 | __END__ | |
24 | ||
25 | =head1 NAME | |
26 | ||
27 | WWW::Offliberty - interface to offliberty.com download service | |
28 | ||
29 | =head1 SYNOPSIS | |
30 | ||
31 | use WWW::Offliberty qw/off/; | |
32 | my @links = off 'http://youtube.com/watch?v=something', video_file => 1; | |
33 | ||
34 | =head1 DESCRIPTION | |
35 | ||
36 | WWW::Offliberty is a simple interface to the offliberty.com download service. | |
37 | ||
38 | It exports a single function: B<off>(I<url>, [I<argument> => value...]). | |
39 | This function that returns a list of download links, | |
40 | as returned by the service. | |
41 | ||
42 | =head1 SEE ALSO | |
43 | ||
44 | L<http://offliberty.com> | |
45 | ||
46 | =head1 AUTHOR | |
47 | ||
48 | Marius Gavrilescu, E<lt>marius@ieval.roE<gt> | |
49 | ||
50 | =head1 COPYRIGHT AND LICENSE | |
51 | ||
52 | Copyright (C) 2013 by Marius Gavrilescu | |
53 | ||
54 | This library is free software; you can redistribute it and/or modify | |
55 | it under the same terms as Perl itself, either Perl version 5.18.1 or, | |
56 | at your option, any later version of Perl 5 you may have available. | |
57 | ||
58 | ||
59 | =cut |