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();
20 $self->{'NAME'} = 'broadcaster';
21 $self->{'PATTERNS'} = ['(http://(?:[-a-zA-Z0-9_.]+\.)*broadcaster\.com/clip/(\d+))'];
24 $self->_prepare_parameters();
35 my $p = videosite::HTMLHelper->new();
41 $metadata->{'URL'} = $url;
42 $metadata->{'ID'} = $2;
43 $metadata->{'TYPE'} = 'video';
44 $metadata->{'SOURCE'} = $self->{'NAME'};
45 $metadata->{'TITLE'} = undef;
46 $metadata->{'DLURL'} = undef;
48 unless(defined($content = $p->load(sprintf('http://www.broadcaster.com/clip/%s', $2)))) {
49 $self->error('Could not download %s', $url);
54 ($metadata->{'TITLE'}) = grep { $_ =~ m|\&page_title=([^\x22]+)\x22|s && {$_ = $1} }
55 map { join("", @{$_->content()}) }
56 grep { defined($_->content()) }
57 $p->findnodes('script');
59 # Look for the download URL
60 ($metadata->{'DLURL'}) = grep { $_ =~ m|\&clip_loc=.+?cache.broadcaster.com.+?escape\(\x22([^\x22]+)\x22\)|s && {$_ = 'http://cache.broadcaster.com/peoplecaster/' .$1} }
61 map { join("", @{$_->content()}) }
62 grep { defined($_->content()) }
63 $p->findnodes('script');
65 unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {
66 $self->error('Could not determine download URL');