]>
Commit | Line | Data |
---|---|---|
de48830a MG |
1 | package WWW::Offliberty; |
2 | ||
a0765f3d | 3 | use 5.008009; |
de48830a MG |
4 | use strict; |
5 | use warnings; | |
6 | use parent qw/Exporter/; | |
925cdb7d | 7 | our $VERSION = '1.000'; |
de48830a MG |
8 | our @EXPORT_OK = qw/off/; |
9 | ||
e90bc616 MG |
10 | use constant OFF_URL => 'http://offliberty.com/off54.php'; |
11 | ||
de48830a | 12 | use HTML::TreeBuilder; |
e90bc616 | 13 | use HTTP::Tiny; |
de48830a | 14 | |
e90bc616 | 15 | my $http = HTTP::Tiny->new(agent => "WWW-Offliberty/$VERSION "); |
de48830a MG |
16 | |
17 | sub 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 | ||
25 | 1; | |
26 | __END__ | |
27 | ||
28 | =head1 NAME | |
29 | ||
30 | WWW::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 | ||
39 | WWW::Offliberty is a simple interface to the offliberty.com download service. | |
40 | ||
d3123fb8 MG |
41 | The module exports (on request) a single function, B<off>(I<url>, |
42 | [I<parameter> => value, ...]). It takes a URL and an optional list of | |
43 | parameters (key/value pairs). It returns a list of download links. An | |
44 | empty list is returned if the Offliberty service returns no URLs (for | |
45 | example if Offliberty encounters an error or the URL is invalid). Dies | |
46 | if unable to contact Offliberty (for example if there is no internet | |
47 | connection or a firewall blocks the connection). | |
48 | ||
49 | The supported services and parameters are undocumented. From empirical | |
50 | testing, when requesting a YouTube URL the service will return an | |
51 | audio-only URL when called with no parameters, and two URLs | |
52 | (audio-only and audio/video) when called with the parameter | |
53 | B<video_file> set to B<1>. In contrast, Vimeo URLs with no parameters | |
54 | return both audio-only and audio/video variants. | |
de48830a MG |
55 | |
56 | =head1 SEE ALSO | |
57 | ||
58 | L<http://offliberty.com> | |
59 | ||
60 | =head1 AUTHOR | |
61 | ||
62 | Marius Gavrilescu, E<lt>marius@ieval.roE<gt> | |
63 | ||
64 | =head1 COPYRIGHT AND LICENSE | |
65 | ||
d3123fb8 | 66 | Copyright (C) 2013-2015 by Marius Gavrilescu |
de48830a MG |
67 | |
68 | This library is free software; you can redistribute it and/or modify | |
69 | it under the same terms as Perl itself, either Perl version 5.18.1 or, | |
70 | at your option, any later version of Perl 5 you may have available. | |
71 | ||
72 | ||
73 | =cut |