From de48830a28800ad0465048ce165b23a74a966265 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Sat, 28 Sep 2013 23:48:38 +0300 Subject: [PATCH] Initial commit --- Changes | 4 +++ MANIFEST | 7 +++++ Makefile.PL | 19 ++++++++++++++ README | 30 ++++++++++++++++++++++ lib/WWW/Offliberty.pm | 59 +++++++++++++++++++++++++++++++++++++++++++ t/00-load.t | 6 +++++ t/50-network.t | 20 +++++++++++++++ 7 files changed, 145 insertions(+) create mode 100644 Changes create mode 100644 MANIFEST create mode 100644 Makefile.PL create mode 100644 README create mode 100644 lib/WWW/Offliberty.pm create mode 100644 t/00-load.t create mode 100644 t/50-network.t diff --git a/Changes b/Changes new file mode 100644 index 0000000..0c43459 --- /dev/null +++ b/Changes @@ -0,0 +1,4 @@ +Revision history for Perl extension WWW::Offliberty. + +0.001 Sat 28 Sep 23:48:00 EEST 2013 + - Initial release diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..36f6cc2 --- /dev/null +++ b/MANIFEST @@ -0,0 +1,7 @@ +Changes +Makefile.PL +MANIFEST +README +t/00-load.t +t/50-network.t +lib/WWW/Offliberty.pm diff --git a/Makefile.PL b/Makefile.PL new file mode 100644 index 0000000..2dd02e0 --- /dev/null +++ b/Makefile.PL @@ -0,0 +1,19 @@ +use ExtUtils::MakeMaker; + +WriteMakefile( + NAME => 'WWW::Offliberty', + VERSION_FROM => 'lib/WWW/Offliberty.pm', + ABSTRACT_FROM => 'lib/WWW/Offliberty.pm', + AUTHOR => 'Marius Gavrilescu ', + MIN_PERL_VERSION => '5.14.0', + LICENSE => 'perl', + SIGN => 1, + PREREQ_PM => { + HTML::TreeBuilder => 0, + LWP::UserAgent => 0, + }, + META_ADD => { + dynamic_config => 0, + repository => 'http://git.ieval.ro/?p=www-offliberty.git' + } +); diff --git a/README b/README new file mode 100644 index 0000000..4497a6c --- /dev/null +++ b/README @@ -0,0 +1,30 @@ +WWW-Offliberty version 0.001 +============================ + +WWW::Offliberty is a simple interface to the offliberty.com download service. + +INSTALLATION + +To install this module type the following: + + perl Makefile.PL + make + make test + make install + +DEPENDENCIES + +This module requires these other modules and libraries: + + * HTML::TreeBuilder + * LWP::UserAgent + +COPYRIGHT AND LICENCE + +Copyright (C) 2013 by Marius Gavrilescu + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself, either Perl version 5.18.1 or, +at your option, any later version of Perl 5 you may have available. + + diff --git a/lib/WWW/Offliberty.pm b/lib/WWW/Offliberty.pm new file mode 100644 index 0000000..fc9c348 --- /dev/null +++ b/lib/WWW/Offliberty.pm @@ -0,0 +1,59 @@ +package WWW::Offliberty; + +use 5.014; +use strict; +use warnings; +use parent qw/Exporter/; +our $VERSION = '0.001'; +our @EXPORT_OK = qw/off/; + +use HTML::TreeBuilder; +use LWP::UserAgent; + +my $ua = LWP::UserAgent->new; + +sub off{ + my ($url, @params) = @_; + my $content = $ua->post("http://offliberty.com/off.php", {track => $url, @params})->decoded_content; + my $root = HTML::TreeBuilder->new_from_content($content); + map { $_->attr('href') } $root->look_down(qw/_tag a class download/); +} + +1; +__END__ + +=head1 NAME + +WWW::Offliberty - interface to offliberty.com download service + +=head1 SYNOPSIS + + use WWW::Offliberty qw/off/; + my @links = off 'http://youtube.com/watch?v=something', video_file => 1; + +=head1 DESCRIPTION + +WWW::Offliberty is a simple interface to the offliberty.com download service. + +It exports a single function: B(I, [I => value...]). +This function that returns a list of download links, +as returned by the service. + +=head1 SEE ALSO + +L + +=head1 AUTHOR + +Marius Gavrilescu, Emarius@ieval.roE + +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2013 by Marius Gavrilescu + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself, either Perl version 5.18.1 or, +at your option, any later version of Perl 5 you may have available. + + +=cut diff --git a/t/00-load.t b/t/00-load.t new file mode 100644 index 0000000..f800658 --- /dev/null +++ b/t/00-load.t @@ -0,0 +1,6 @@ +#!/usr/bin/perl -w +use strict; +use warnings; + +use Test::More tests => 1; +BEGIN { use_ok('WWW::Offliberty') }; diff --git a/t/50-network.t b/t/50-network.t new file mode 100644 index 0000000..b940cc8 --- /dev/null +++ b/t/50-network.t @@ -0,0 +1,20 @@ +#!/usr/bin/perl -w +use strict; +use warnings; + +use Test::More; +use WWW::Offliberty qw/off/; + +if ($ENV{NETWORK_TEST}) { + plan tests => 2; + + my @results; + + @results = off "http://youtube.com/watch?v=Tj75Arhq5ho"; + is @results, 1, 'youtube'; + + @results = off "http://youtube.com/watch?v=Tj75Arhq5ho", video_file => 1; + is @results, 2, 'youtube, video_file => 1'; +} else { + plan skip_all => '$ENV{NETWORK_TEST} not true'; +} -- 2.39.2