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