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
::Golem
;
26 # --format=(high|medium|ipod)
28 # medium = default (what we call "flv" in clive)
31 # Note that we do not use "medium" at all. The host
32 # defaults to "medium" if "?q=" is not appended.
33 # Users do not need to bother themselves with this.
35 # We use config:title instead of video page title
36 # if it can be parsed from the config. Saves us
37 # the trouble from cleaning up the <title>.
40 return bless( {}, shift );
44 my ( $self, $content, $props ) = @_;
46 $$props->video_host("golem");
48 my %re = ( id
=> qr
|"id", "(.*?)"| );
51 if ( clive
::Util
::matchRegExps
( \
%re, \
$tmp, $content ) == 0 ) {
52 my $url = "http://video.golem.de/xml/$tmp->{id}";
53 if ( _fetchConfig
( $self, $url, $tmp->{id
} ) == 0 ) {
55 $$props->page_title( undef, $self->{page_title
} )
56 if ( $self->{page_title
} );
58 $$props->video_id( $tmp->{id
} );
59 $$props->video_link( $self->{video_link
} );
68 my ( $self, $url, $id ) = @_;
70 my $curl = clive
::Curl
->instance;
73 if ( $curl->fetchToMem( $url, \
$content, "config" ) == 0 ) {
75 my $xurl = "http://video.golem.de/download/$id";
76 my $config = clive
::Config
->instance->config;
79 if ( $content =~ /<title>(.*?)<\/title
>/ );
82 if ( $config->{format
} eq "best" ) {
84 my %re = ( path
=> qr
|<filename
>(.*?
)</filename
>| );
85 my @fnames = $content =~ /$re{path}/g;
87 foreach my $i (qw
/hd sd ipod/) {
88 if ( my @b = grep( /$i/, @fnames ) ) {
95 $fmt =~ s/sd//; # medium
98 $fmt = $config->{format
};
99 $fmt =~ s/flv//; # medium (default)
105 $self->{page_title
} = $title;
106 $self->{video_link
} = $xurl;
116 # And the wind began to howl.