]> iEval git - www-offliberty.git/blame_incremental - lib/WWW/Offliberty.pm
Bump version and update Changes
[www-offliberty.git] / lib / WWW / Offliberty.pm
... / ...
CommitLineData
1package WWW::Offliberty;
2
3use 5.008009;
4use strict;
5use warnings;
6use parent qw/Exporter/;
7our $VERSION = '1.000002';
8our @EXPORT_OK = qw/off/;
9
10use constant OFF_URL => 'http://offliberty.com/off02.php';
11
12use HTML::TreeBuilder;
13use HTTP::Tiny;
14
15our $http = HTTP::Tiny->new(agent => "WWW-Offliberty/$VERSION ", default_headers => {Referer => 'http://offliberty.com/'});
16
17sub off{
18 my ($url, @params) = @_;
19 my $ret = $http->post_form(OFF_URL, {track => $url, @params});
20 die $ret->{reason} unless $ret->{success}; ## no critic (RequireCarping)
21 my $root = HTML::TreeBuilder->new_from_content($ret->{content});
22 map { $_->attr('href') } $root->look_down(qw/_tag a class download/);
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
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.
55
56=head1 SEE ALSO
57
58L<http://offliberty.com>
59
60=head1 AUTHOR
61
62Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
63
64=head1 COPYRIGHT AND LICENSE
65
66Copyright (C) 2013-2015 by Marius Gavrilescu
67
68This library is free software; you can redistribute it and/or modify
69it under the same terms as Perl itself, either Perl version 5.18.1 or,
70at your option, any later version of Perl 5 you may have available.
71
72
73=cut
This page took 0.021415 seconds and 4 git commands to generate.