1 # (c) 2007 by Ralf Ertzinger <ralf@camperquake.de>
2 # licensed under GNU GPL v2
9 @ISA = qw(GrabberBase);
11 use LWP::Simple qw(!get);
20 my $self = $class->SUPER::new();
22 $self->{'NAME'} = 'bliptv';
23 $self->{'PATTERNS'} = ['(http://(?:[-a-zA-Z0-9_.]+\.)*blip.tv/file/(\d+)(?:\?\S+)?)'];
26 $self->_prepare_parameters();
37 my $p = HTML::Parser->new(api_version => 3);
46 $metadata->{'URL'} = $url;
47 $metadata->{'ID'} = $2;
48 $metadata->{'TYPE'} = 'video';
49 $metadata->{'SOURCE'} = $self->{"NAME"};
50 $metadata->{'TITLE'} = undef;
51 $metadata->{'DLURL'} = undef;
53 unless(defined($content = LWP::Simple::get(sprintf('http://blip.tv/file/%s', $2)))) {
54 $self->error('Could not download page');
58 $p->handler(start => \@accum, "tagname, attr");
59 $p->handler(text => \@text, "text");
60 $p->report_tags(qw(script));
64 # Look for the post id in the javascript code
66 if ($e->[0] =~ m|player.setPostsId\((\d+)\)|s) {
71 unless(defined($xml)) {
72 $self->error("Could not find post id");
76 # Download the XML file containing the stream information
77 unless(defined($content = LWP::Simple::get(sprintf('http://blip.tv/rss/flash/%s', $xml)))) {
78 $self->error('Could not download XML metadata');
82 $xml = XML::Simple::XMLin($content, KeepRoot => 1);
83 $metadata->{'DLURL'} = $xml->{'rss'}->{'channel'}->{'item'}->{'enclosure'}->{'url'};
84 $metadata->{'TITLE'} = $xml->{'rss'}->{'channel'}->{'item'}->{'media:title'};
86 unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {
87 $self->error('Could not determine download URL');