From bb930ff32f3b4bb4081037550760e4f82af4c39f Mon Sep 17 00:00:00 2001 From: Ralf Ertzinger Date: Sat, 23 Jul 2011 22:51:10 +0200 Subject: [PATCH] CollegeHumor: Fix video URLs, and the title is in the XML now! --- videosite/CollegeHumorGrabber.pm | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/videosite/CollegeHumorGrabber.pm b/videosite/CollegeHumorGrabber.pm index bbf54a6..fb03286 100644 --- a/videosite/CollegeHumorGrabber.pm +++ b/videosite/CollegeHumorGrabber.pm @@ -20,7 +20,8 @@ sub new { my $self = $class->SUPER::new(); $self->{'NAME'} = 'collegehumor'; - $self->{'PATTERNS'} = ['(http://www.collegehumor.com/video:(\d+))']; + $self->{'PATTERNS'} = ['(http://www.collegehumor.com/video:(\d+))', + '(http://www.collegehumor.com/video/(\d+))']; bless($self, $class); $self->_prepare_parameters(); @@ -49,7 +50,7 @@ sub _parse { $metadata->{'DLURL'} = undef; # Get the XML file containing the video metadata - unless(defined($content = LWP::Simple::get(sprintf('http://www.collegehumor.com/moogaloop/video:%s', $2)))) { + unless(defined($content = LWP::Simple::get(sprintf('http://www.collegehumor.com/moogaloop/video/%s', $2)))) { $self->error('Could not download XML metadata'); return undef; } @@ -60,20 +61,7 @@ sub _parse { } $metadata->{'DLURL'} = $t->{'video'}->{'file'}; - - # The XML does not contain the full title of the video, for - # reasons possibly known to some jerk at CollegeHumor. - # So we'll have to parse the actual HTML, too. - $p = videosite::HTMLHelper->new(); - unless(defined($content = $p->load(sprintf('http://www.collegehumor.com/video:%s', $2)))) { - $self->error('Could not download HTML'); - return undef; - } - - $t = $p->findnodes('h1[@id="item_title"]'); - if (defined($t)) { - $metadata->{'TITLE'} = $t->{'_content'}->[0]; - } + $metadata->{'TITLE'} = $t->{'video'}->{'caption'}; unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) { $self->error('Could not extract download URL and title'); -- 1.8.3.1