]> git.pld-linux.org Git - packages/clive.git/blame - clive-delfi.patch
- updated for 2.1.10
[packages/clive.git] / clive-delfi.patch
CommitLineData
75b3b1fb 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 @@
94810194 4 IsEvisor => qr|evisor.tv|i,
5 IsDmotion => qr|dailymotion.com|i,
75b3b1fb 6 IsCctv => qr|tv.cctv.com|i,
94810194 7+ IsDelfi => qr|.delfi.|i,
8 );
1b2ddcae 9
75b3b1fb 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
94810194 19@@ -992,6 +993,64 @@
4aadb41e
ER
20 return ($xurl, $id);
21 }
22
23+sub handle_delfi {
67a1036f 24+ my ($response_ref, $response_fh) = @_;
94810194 25+
67a1036f
ER
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+ );
4aadb41e 38+
67a1036f
ER
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}/;
4aadb41e 44+
67a1036f
ER
45+ if ($videobox_url) {
46+ $id = $1 if $videobox_url =~ m{/([^/]+)\.flv$};
47+ $xurl = $videobox_url;
4aadb41e 48+
67a1036f 49+ } elsif ($video_url) {
a41b35f4 50+ $xurl = URI::Escape::uri_unescape($video_url);
67a1036f 51+ $id = $1 if $xurl =~ m{^\S+://[^/]+/v/(.+?)\.flv};
4aadb41e 52+
67a1036f
ER
53+ } elsif ($video_salt and $video_site) {
54+ my $url = $video_site . '/video/' . $video_salt . '/';
55+ print "done.\nfetch page ..." unless $opts{quiet};
4aadb41e 56+
67a1036f
ER
57+ my $page = "";
58+ open my $fh, ">", \$page;
4aadb41e 59+
67a1036f
ER
60+ # Disable: header
61+ $curl->setopt(CURLOPT_HEADER, 0);
62+ $curl->setopt(CURLOPT_URL, $url);
63+ $curl->setopt(CURLOPT_WRITEDATA, $fh);
4aadb41e 64+
67a1036f
ER
65+ my $rc = $curl->perform;
66+ close $fh;
4aadb41e 67+
67a1036f
ER
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+ }
4aadb41e 77+
67a1036f 78+ return ($xurl, $id);
4aadb41e 79+}
67a1036f 80+
4aadb41e
ER
81 # Subroutines: Progress
82 # NOTE: the 'dot' progress copies much from wget.
This page took 0.081813 seconds and 4 git commands to generate.