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
::Youtube
;
26 # fmt22 = HD[1280x720]
28 # fmt17 = 3gp[176x144]
29 # fmt18 = mp4[480x360]
30 # fmt34 = flv[320x180]
33 return bless( {}, shift );
37 my ( $self, $content, $props ) = @_;
39 $$props->video_host("youtube");
42 id
=> qr
|"video_id": "(.*?)"|,
43 t
=> qr
|"t": "(.*?)"|,
47 if ( clive
::Util
::matchRegExps
( \
%re, \
$tmp, $content ) == 0 ) {
50 = "http://youtube.com/get_video?video_id=$tmp->{id}&t=$tmp->{t}";
52 my $config = clive
::Config
->instance->config;
56 if ( $config->{format
} eq "best" ) {
58 if $$content =~ /"fmt_map": "(.*?)\//;
62 if toFmt
( $self, $config->{format
} ) =~ /^fmt(.*)$/;
68 $$props->video_id( $tmp->{id
} );
69 $$props->video_link($xurl);
77 my ( $self, $id ) = @_;
87 # And this is not our fate.