X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=videosite%2FYahooGrabber.pm;h=4c88842f09ca0ee81d559455e4eb47ca377a7856;hb=1dd46d87d78c3cac2732ba942f4412f3a168a837;hp=4c9833254d7baa306c625a1d8b52b3436d9fa3ca;hpb=5dec08312ac5618cb2b20a497f7b96142d8d48ca;p=videosite.git diff --git a/videosite/YahooGrabber.pm b/videosite/YahooGrabber.pm index 4c98332..4c88842 100644 --- a/videosite/YahooGrabber.pm +++ b/videosite/YahooGrabber.pm @@ -3,12 +3,11 @@ # # Grabber for video.yahoo.com -package YahooGrabber; +package videosite::YahooGrabber; -use GrabberBase; -@ISA = qw(GrabberBase); +use videosite::GrabberBase; +@ISA = qw(videosite::GrabberBase); -use LWP::Simple qw(!get); use XML::Simple; use HTML::Parser; use Data::Dumper; @@ -17,15 +16,13 @@ use strict; sub new { my $class = shift; - my $self = $class->SUPER::new(); + my $self = $class->SUPER::new( + NAME => 'yahoo', + PATTERNS => ['(http://video\.yahoo\.com/watch/\d+/(\d+))'], + @_, + ); - $self->{'NAME'} = 'yahoo'; - $self->{'PATTERNS'} = ['(http://video\.yahoo\.com/watch/\d+/(\d+))']; - - bless($self, $class); - $self->_prepare_parameters(); - - return $self; + return bless($self, $class); } sub _parse { @@ -37,6 +34,7 @@ sub _parse { my $p = XML::Simple->new(); my $t; my @accum; + my $ua = $self->ua(); $url =~ m|$pattern|; $url = $1; @@ -49,7 +47,7 @@ sub _parse { $metadata->{'DLURL'} = undef; # Get the XML file containing the video metadata - unless(defined($content = LWP::Simple::get(sprintf('http://cosmos.bcst.yahoo.com/up/yep/process/getPlaylistFOP.php?node_id=%s', $2)))) { + unless(defined($content = $self->simple_get(sprintf('http://cosmos.bcst.yahoo.com/up/yep/process/getPlaylistFOP.php?node_id=%s', $2), $ua))) { $self->error('Could not download XML metadata'); return undef; } @@ -63,11 +61,12 @@ sub _parse { } $metadata->{'DLURL'} = $t->{'DATA'}->{'SEQUENCE-ITEM'}->{'STREAM'}->{'APP'} . $t->{'DATA'}->{'SEQUENCE-ITEM'}->{'STREAM'}->{'FULLPATH'}; + $metadata->{'DLURL'} =~ s/\&/\&/g; # The XML does not contain the title of the video, for # reasons possibly known to some jerk at yahoo. # So we'll have to parse the actual HTML, too. - unless(defined($content = LWP::Simple::get($url))) { + unless(defined($content = $self->simple_get($url, $ua))) { $self->error('Could not download HTML'); return undef; }