# (c) 2007 by Ralf Ertzinger <ralf@camperquake.de>
# licensed under GNU GPL v2
-package CollegeHumorGrabber;
+package videosite::CollegeHumorGrabber;
-use GrabberBase;
-@ISA = qw(GrabberBase);
+use videosite::GrabberBase;
+@ISA = qw(videosite::GrabberBase);
+use videosite::HTMLHelper;
use LWP::Simple qw(!get);
use XML::Simple;
-use HTML::Parser;
use Data::Dumper;
use strict;
# 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.
- unless(defined($content = LWP::Simple::get(sprintf('http://www.collegehumor.com/video:%s', $2)))) {
+ $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;
}
- $p = HTML::Parser->new(api_version => 3);
-
- $p->handler(start => \@accum, "tagname, attr");
- $p->report_tags(qw(meta));
- $p->utf8_mode(1);
- $p->parse($content);
-
- # Look for the title in the meta tags
- foreach $t (@accum) {
- if ('meta' eq $t->[0]) {
- if (exists($t->[1]->{'name'}) and ('title' eq $t->[1]->{'name'})) {
- $metadata->{'TITLE'} = $t->[1]->{'content'};
- }
- }
+
+ $t = $p->findnodes('h1[@id="item_title"]');
+ if (defined($t)) {
+ $metadata->{'TITLE'} = $t->{'_content'}->[0];
}
unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {