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+))'],
24 return bless($self, $class);
33 my $p = videosite::HTMLHelper->new();
39 $metadata->{'URL'} = $url;
40 $metadata->{'ID'} = $2;
41 $metadata->{'TYPE'} = 'video';
42 $metadata->{'SOURCE'} = $self->{'NAME'};
43 $metadata->{'TITLE'} = undef;
44 $metadata->{'DLURL'} = undef;
46 unless(defined($content = $p->load(sprintf('http://www.broadcaster.com/clip/%s', $2)))) {
47 $self->error('Could not download %s', $url);
52 ($metadata->{'TITLE'}) = grep { $_ =~ m|\&page_title=([^\x22]+)\x22|s && {$_ = $1} }
53 map { join("", @{$_->content()}) }
54 grep { defined($_->content()) }
55 $p->findnodes('script');
57 # Look for the download URL
58 ($metadata->{'DLURL'}) = grep { $_ =~ m|\&clip_loc=.+?cache.broadcaster.com.+?escape\(\x22([^\x22]+)\x22\)|s && {$_ = 'http://cache.broadcaster.com/peoplecaster/' .$1} }
59 map { join("", @{$_->content()}) }
60 grep { defined($_->content()) }
61 $p->findnodes('script');
63 unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {
64 $self->error('Could not determine download URL');