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