1 # -*- coding: ascii -*-
2 ###########################################################################
3 # clive, command line video extraction utility.
4 # Copyright 2007, 2008, 2009 Toni Gundogdu.
6 # This file is part of clive.
8 # clive is free software: you can redistribute it and/or modify it under
9 # the terms of the GNU General Public License as published by the Free
10 # Software Foundation, either version 3 of the License, or (at your option)
13 # clive is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18 # You should have received a copy of the GNU General Public License along
19 # with this program. If not, see <http://www.gnu.org/licenses/>.
20 ###########################################################################
21 package clive
::Host
::Vimeo
;
27 return bless( {}, shift );
31 my ( $self, $content, $props ) = @_;
33 $$props->video_host("vimeo");
36 id
=> qr
|clip_id
=(.*?
)"|,
37 title => qr|name="title
" content="(.*?
)"|
41 if ( clive::Util::matchRegExps( \%re, \$tmp, $content ) == 0 ) {
42 my $config = "http
://vimeo
.com
/moogaloop
/load
/clip
:$tmp->{id
}";
44 if ( _parseConfig( $self, $config, $tmp->{id} ) == 0 ) {
45 $$props->video_id( $tmp->{id} );
46 $$props->video_link( $self->{video_link} );
48 # Less hassle than using <title>.
49 $$props->page_title( undef, $tmp->{title} );
58 my ( $self, $url, $id ) = @_;
60 my $curl = clive::Curl->instance;
63 if ( $curl->fetchToMem( $url, \$content, "config
" ) == 0 ) {
65 sig => qr|<request_signature>(.*?)</request_signature>|,
67 qr|request_signature_expires>(.*?)</request_signature_expires>|
71 if ( clive::Util::matchRegExps( \%re, \$tmp, \$content ) == 0 ) {
72 my $xurl = "http
://vimeo
.com
/moogaloop
/play
/clip
:$id"
73 . "/$tmp->{sig}/$tmp->{sig_exp
}";
74 my $config = clive::Config->instance->config;
75 if ( $config->{format} eq "hd
"
76 || $config->{format} eq "best
" )
79 if ( $content =~ /<hd_button>(.*?)<\/hd_button>/ );
81 if ( $hd_avail && $hd_avail eq "1" );
83 $self->{video_link} = $xurl;
92 # So let us not talk falsely now.