Bump version and update Changes
[www-offliberty.git] / lib / WWW / Offliberty.pm
CommitLineData
de48830a
MG
1package WWW::Offliberty;
2
a0765f3d 3use 5.008009;
de48830a
MG
4use strict;
5use warnings;
6use parent qw/Exporter/;
c9bd8d30 7our $VERSION = '1.000003';
de48830a
MG
8our @EXPORT_OK = qw/off/;
9
fe61815e 10our $OFF_URL = 'http://offliberty.com/off03.php';
e90bc616 11
de48830a 12use HTML::TreeBuilder;
e90bc616 13use HTTP::Tiny;
de48830a 14
c5b1f2e7 15our $http = HTTP::Tiny->new(agent => "WWW-Offliberty/$VERSION ", default_headers => {Referer => 'http://offliberty.com/'});
de48830a
MG
16
17sub off{
000e3496 18 my ($url, @params) = @_;
fe61815e 19 my $ret = $http->post_form($OFF_URL, {track => $url, @params});
c5b1f2e7 20 die $ret->{reason} unless $ret->{success}; ## no critic (RequireCarping)
e90bc616 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
d3123fb8
MG
41The module exports (on request) a single function, B<off>(I<url>,
42[I<parameter> => value, ...]). It takes a URL and an optional list of
43parameters (key/value pairs). It returns a list of download links. An
44empty list is returned if the Offliberty service returns no URLs (for
45example if Offliberty encounters an error or the URL is invalid). Dies
46if unable to contact Offliberty (for example if there is no internet
47connection or a firewall blocks the connection).
48
49The supported services and parameters are undocumented. From empirical
50testing, when requesting a YouTube URL the service will return an
51audio-only URL when called with no parameters, and two URLs
52(audio-only and audio/video) when called with the parameter
53B<video_file> set to B<1>. In contrast, Vimeo URLs with no parameters
54return both audio-only and audio/video variants.
de48830a 55
fe61815e
MG
56Note: The URL of the service sometimes changes, which breaks this
57module. If you notice this, please report a bug on RT. While the bug
58is being fixed, you can override the URL locally by doing:
59
60 $WWW::Offliberty:OFF_URL = 'http://offliberty.com/correct_url.php';
61
62before calling off.
63
de48830a
MG
64=head1 SEE ALSO
65
66L<http://offliberty.com>
67
68=head1 AUTHOR
69
70Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
71
72=head1 COPYRIGHT AND LICENSE
73
d3123fb8 74Copyright (C) 2013-2015 by Marius Gavrilescu
de48830a
MG
75
76This library is free software; you can redistribute it and/or modify
77it under the same terms as Perl itself, either Perl version 5.18.1 or,
78at your option, any later version of Perl 5 you may have available.
79
80
81=cut
This page took 0.01508 seconds and 4 git commands to generate.