1 # (c) 2007 by Ralf Ertzinger <ralf@camperquake.de>
2 # licensed under GNU GPL v2
4 # Grabber for broadcaster.com
6 package videosite::BroadcasterGrabber;
8 use videosite::GrabberBase;
9 @ISA = qw(videosite::GrabberBase);
11 use videosite::HTMLHelper;
18 my $self = $class->SUPER::new(
19 NAME => 'broadcaster',
20 PATTERNS => ['(http://(?:[-a-zA-Z0-9_.]+\.)*broadcaster\.com/clip/(\d+))'],
23 return bless($self, $class);
32 my $p = videosite::HTMLHelper->new();
38 $metadata->{'URL'} = $url;
39 $metadata->{'ID'} = $2;
40 $metadata->{'TYPE'} = 'video';
41 $metadata->{'SOURCE'} = $self->{'NAME'};
42 $metadata->{'TITLE'} = undef;
43 $metadata->{'DLURL'} = undef;
45 unless(defined($content = $p->load(sprintf('http://www.broadcaster.com/clip/%s', $2)))) {
46 $self->error('Could not download %s', $url);
51 ($metadata->{'TITLE'}) = grep { $_ =~ m|\&page_title=([^\x22]+)\x22|s && {$_ = $1} }
52 map { join("", @{$_->content()}) }
53 grep { defined($_->content()) }
54 $p->findnodes('script');
56 # Look for the download URL
57 ($metadata->{'DLURL'}) = grep { $_ =~ m|\&clip_loc=.+?cache.broadcaster.com.+?escape\(\x22([^\x22]+)\x22\)|s && {$_ = 'http://cache.broadcaster.com/peoplecaster/' .$1} }
58 map { join("", @{$_->content()}) }
59 grep { defined($_->content()) }
60 $p->findnodes('script');
62 unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {
63 $self->error('Could not determine download URL');