# (c) 2007 by Ralf Ertzinger # licensed under GNU GPL v2 # # Grabber for broadcaster.com package videosite::BroadcasterGrabber; use videosite::GrabberBase; @ISA = qw(videosite::GrabberBase); use videosite::HTMLHelper; use Data::Dumper; use strict; sub new { my $class = shift; my $self = $class->SUPER::new( NAME => 'broadcaster', PATTERNS => ['(http://(?:[-a-zA-Z0-9_.]+\.)*broadcaster\.com/clip/(\d+))'], @_, ); return bless($self, $class); } sub _parse { my $self = shift; my $url = shift; my $pattern = shift; my $content; my $metadata = {}; my $p = videosite::HTMLHelper->new(); my $n; $url =~ m|$pattern|; $url = $1; $metadata->{'URL'} = $url; $metadata->{'ID'} = $2; $metadata->{'TYPE'} = 'video'; $metadata->{'SOURCE'} = $self->{'NAME'}; $metadata->{'TITLE'} = undef; $metadata->{'DLURL'} = undef; unless(defined($content = $p->load(sprintf('http://www.broadcaster.com/clip/%s', $2)))) { $self->error('Could not download %s', $url); return undef; } # Look for the title ($metadata->{'TITLE'}) = grep { $_ =~ m|\&page_title=([^\x22]+)\x22|s && {$_ = $1} } map { join("", @{$_->content()}) } grep { defined($_->content()) } $p->findnodes('script'); # Look for the download URL ($metadata->{'DLURL'}) = grep { $_ =~ m|\&clip_loc=.+?cache.broadcaster.com.+?escape\(\x22([^\x22]+)\x22\)|s && {$_ = 'http://cache.broadcaster.com/peoplecaster/' .$1} } map { join("", @{$_->content()}) } grep { defined($_->content()) } $p->findnodes('script'); unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) { $self->error('Could not determine download URL'); return undef; } return $metadata; } 1;