FIX: website/liveleak.lua: media stream URL pattern
[libquvi-scripts.git] / tests / t / expire.t
blob9261a82d6eb1a5e8a94637483ce5603379b76950
1 # libquvi-scripts
2 # Copyright (C) 2011,2013  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 POSIX qw(ceil);
23 use Test::More;
25 eval "use LWP::UserAgent";
26 plan skip_all => "LWP::UserAgent required for testing" if $@;
28 use Test::Quvi;
30 my $q = Test::Quvi->new;
31 #plan skip_all => "FIXME";
32 plan skip_all => "TEST_SKIP rule" if $q->test_skip("expire");
34 my $ua = new LWP::UserAgent;
35 $ua->env_proxy;
37 my %h = (
38   "http://videos.arte.tv" => sub {
39     my ($p) = @_;
40     my $q = qr|<h2><a href="/(\w\w)/videos/(.*?)"|;
41     my @l;
42     push @l, "http://videos.arte.tv/$1/videos/$2"  while $p =~ /$q/g;
43     my $n = ceil(scalar @l/2);
44     $l[$n];
45   },
47 =for comment
48   "http://www.pluzz.fr/" => sub {
49     my ($page, $url) = @_;
50     my $rx_href = qr|class=""\s+href="(.*?)"|i;
51     my $rx_url  = qr|$url|;
52     for my $c ($page =~ /$rx_href/g)
53     {
54       return $c if $c =~ /$rx_url/;
55     }
56   }
57 =cut
59 plan tests => scalar(keys %h) * 2;
61 foreach (keys %h)
63   note "fetching $_ ...";
64   my $r = $ua->request(HTTP::Request->new(GET => $_));
65   is($r->is_success, 1, "request is success") or diag $r->status_line;
66 SKIP:
67   {
68     skip 'request failed', 1 unless $r->is_success;
69     note "matching...";
70     my $url = $h{$_}($r->decoded_content, $_);
71   SKIP:
72     {
73       skip 'no match: url', 1 unless $url;
74       note "querying media...";
75       ($r) = $q->run($url, "-vq -e-r");
76       is($r, 0x00, "quvi exit status == QUVI_OK")
77         or diag $url;
78     }
79   }
82 # vim: set ts=2 sw=2 tw=72 expandtab: