]> git.pld-linux.org Git - packages/clive.git/blob - clive-delfi.patch
- updated for 2.1.10
[packages/clive.git] / clive-delfi.patch
1 --- clive-2.1.10/clive~ 2009-04-27 11:14:37.000000000 +0200
2 +++ clive-2.1.10/clive  2009-04-27 11:21:15.000000000 +0200
3 @@ -87,6 +87,7 @@
4                   IsEvisor    => qr|evisor.tv|i,
5                   IsDmotion   => qr|dailymotion.com|i,
6                   IsCctv      => qr|tv.cctv.com|i,
7 +                 IsDelfi     => qr|.delfi.|i,
8                 );
9
10  my @re_hosts_arr = (
11 @@ -99,6 +100,7 @@
12                      [$re_hosts{IsEvisor},    \&handle_evisor],
13                      [$re_hosts{IsDmotion},   \&handle_dmotion],
14                      [$re_hosts{IsCctv},      \&handle_cctv],
15 +                    [$re_hosts{IsDelfi},     \&handle_delfi],
16                     );
17
18  # Parse config              
19 @@ -992,6 +993,64 @@
20      return ($xurl, $id);
21  }
22  
23 +sub handle_delfi {
24 +    my ($response_ref, $response_fh) = @_;
25
26 +    my %re = (
27 +    # videobox
28 +    # http://www.delfi.ee/news/paevauudised/paevavideo/article.php?id=15218215
29 +        GrabVideoboxURL => qr|flv_url:\s*'(.*?)'|,
30 +    # videoproject embed
31 +    # http://www.delfi.ee/news/paevauudised/paevavideo/article.php?id=18759038
32 +        GrabVideoSalt   => qr|_delfiVideoSalt\s*=\s*"([^"]+)";|,
33 +        GrabVideoSite   => qr|src="(\S+://[^/]+)/js/embed.js"|,
34 +    # videoproject
35 +    # http://video.delfi.ee/video/CzurzqNz/
36 +        GrabVideoURL   => qr|\.addVariable\('file',\s*'([^']+)'|,
37 +    );
38 +
39 +    my ($xurl, $id);
40 +    my $videobox_url = $1 if $$response_ref =~ /$re{GrabVideoboxURL}/;
41 +    my $video_salt   = $1 if $$response_ref =~ /$re{GrabVideoSalt}/;
42 +    my $video_site   = $1 if $$response_ref =~ /$re{GrabVideoSite}/;
43 +    my $video_url   = $1 if $$response_ref =~ /$re{GrabVideoURL}/;
44 +
45 +    if ($videobox_url) {
46 +        $id = $1 if $videobox_url =~ m{/([^/]+)\.flv$};
47 +        $xurl = $videobox_url;
48 +
49 +    } elsif ($video_url) {
50 +        $xurl = URI::Escape::uri_unescape($video_url);
51 +        $id = $1 if $xurl =~ m{^\S+://[^/]+/v/(.+?)\.flv};
52 +
53 +    } elsif ($video_salt and $video_site) {
54 +        my $url = $video_site . '/video/' . $video_salt . '/';
55 +        print "done.\nfetch page ..." unless $opts{quiet};
56 +
57 +        my $page = "";
58 +        open my $fh, ">", \$page;
59 +
60 +        # Disable: header
61 +        $curl->setopt(CURLOPT_HEADER, 0);
62 +        $curl->setopt(CURLOPT_URL, $url);
63 +        $curl->setopt(CURLOPT_WRITEDATA, $fh);
64 +
65 +        my $rc = $curl->perform;
66 +        close $fh;
67 +
68 +        if ($rc == 0) {
69 +            # recurse
70 +            ($xurl, $id) = handle_delfi(\$page);
71 +        } else {
72 +            print STDERR "\nerror: " . $curl->strerror($rc) . " (http/$rc)\n";
73 +        }
74 +    } else {
75 +        print STDERR "error: url not found\n";
76 +    }
77 +
78 +    return ($xurl, $id);
79 +}
80 +
81  # Subroutines: Progress
82  # NOTE: the 'dot' progress copies much from wget.
This page took 0.100221 seconds and 4 git commands to generate.