1 # -*- coding: ascii -*-
2 ###########################################################################
3 # clive, command line video extraction utility.
5 # Copyright 2009 Toni Gundogdu.
7 # This file is part of clive.
9 # clive is free software: you can redistribute it and/or modify it under
10 # the terms of the GNU General Public License as published by the Free
11 # Software Foundation, either version 3 of the License, or (at your option)
14 # clive is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19 # You should have received a copy of the GNU General Public License along
20 # with this program. If not, see <http://www.gnu.org/licenses/>.
21 ###########################################################################
22 package clive
::Host
::Dailymotion
;
27 use clive
::Error
qw(CLIVE_FORMAT);
29 # ON2-1280x720 (vp6-hd)
30 # ON2-848x480 (vp6-hq)
34 # FLV-80x60 (spak-mini)
37 return bless( {}, shift );
41 my ( $self, $content, $props ) = @_;
43 $$props->video_host("dailymotion");
46 id
=> qr
|video
/(.*?
)_
|,
47 paths
=> qr
|"video", "(.*?)"|
51 if ( clive
::Util
::matchRegExps
( \
%re, \
$tmp, $content ) == 0 ) {
54 my $paths = URI
::Escape
::uri_unescape
( $tmp->{paths
} );
55 my $config = clive
::Config
->instance->config;
57 my $format = $config->{format
};
58 $format = "spark" if ( $format eq "flv" );
63 foreach ( split( /\|\|/, $paths ) ) {
64 my ( $path, $type ) = split(/@@/);
67 if ( $path =~ /cdn\/(.*)-(.*?
)x
/ );
69 if ( lc($type) eq $format
70 && $format ne "best" )
77 if ( $format eq "best" ) {
79 # Sort by width to descending order, assume [0] to be the best.
80 my $best = ( sort { $b <=> $a } keys %width )[0];
81 $xurl = $width{$best};
85 $$props->video_id( $tmp->{id
} );
86 $$props->video_link($xurl);
90 clive
::Log
->instance->err( CLIVE_FORMAT
,
91 "format unavailable: `$format'" );
99 # Nobody of it is worth.