c3e2fee51918cd4d5a61e3705ae2df57ba9b4f15
[libquvi-scripts.git] / tests / t / expire.t
blobc3e2fee51918cd4d5a61e3705ae2df57ba9b4f15
1 # libquvi-scripts
2 # Copyright (C) 2011  Toni Gundogdu <legatvs@gmail.com>
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 # 02110-1301, USA.
19 use warnings;
20 use strict;
22 use Test::More;
24 eval "use LWP::UserAgent";
25 plan skip_all => "LWP::UserAgent required for testing" if $@;
27 use Test::Quvi;
29 my $q = Test::Quvi->new;
30 plan skip_all => "TEST_SKIP rule" if $q->test_skip("expire");
32 my $ua = new LWP::UserAgent;
33 $ua->env_proxy;
35 my %h = (
36   "http://videos.arte.tv" => sub {
37     my $qr = qr|<h2><a href="/(\w\w)/videos/(.*?)"|;
38     my ($page) = @_;
39     "http://videos.arte.tv/$1/videos/$2" if $page =~ /$qr/;
40   },
42 =for comment FIXME: pluzz.lua
43   "http://www.pluzz.fr/" => sub {
44     my ($page, $url) = @_;
45     my $rx_href = qr|class=""\s+href="(.*?)"|i;
46     my $rx_url  = qr|$url|;
47     for my $c ($page =~ /$rx_href/g)
48     {
49       return $c if $c =~ /$rx_url/;
50     }
51   }
52 =cut
54 plan tests => scalar(keys %h) * 2;
56 foreach (keys %h)
58   note "fetching $_ ...";
59   my $r = $ua->request(HTTP::Request->new(GET => $_));
60   is($r->is_success, 1, "request is success") or diag $r->status_line;
61 SKIP:
62   {
63     skip 'request failed', 1 unless $r->is_success;
64     note "matching...";
65     my $url = $h{$_}($r->decoded_content, $_);
66   SKIP:
67     {
68       skip 'no match: url', 1 unless $url;
69       note "querying media...";
70       ($r) = $q->run($url, "-vq -e-r");
71       is($r, 0x00, "quvi exit status == QUVI_OK")
72         or diag $url;
73     }
74   }
77 # vim: set ts=2 sw=2 tw=72 expandtab: