Youtube: Disable the scrap handlers for the 2009 and 2010 page formats, they should...
[videosite.git] / videosite / CollegeHumorGrabber.pm
index 9fdb87e..7fb3cae 100644 (file)
@@ -1,9 +1,14 @@
-package CollegeHumorGrabber;
+# Grabber for collegehumor.com
+#
+# (c) 2007 by Ralf Ertzinger <ralf@camperquake.de>
+# licensed under GNU GPL v2
 
-use GrabberBase;
-@ISA = qw(GrabberBase);
+package videosite::CollegeHumorGrabber;
 
-use LWP::Simple qw(!get);
+use videosite::GrabberBase;
+@ISA = qw(videosite::GrabberBase);
+
+use videosite::HTMLHelper;
 use XML::Simple;
 use Data::Dumper;
 
@@ -14,7 +19,10 @@ sub new {
     my $self = $class->SUPER::new();
 
     $self->{'NAME'} = 'collegehumor';
-    $self->{'PATTERNS'} = ['(http://www.collegehumor.com/video:(\d+))'];
+    $self->{_SELFTESTURL} = 'http://www.collegehumor.com/video/5635400/pixar-intro-parody';
+    $self->{_SELFTESTTITLE} = 'Pixar Intro Parody';
+    $self->{'PATTERNS'} = ['(http://www.collegehumor.com/video:(\d+))',
+                           '(http://www.collegehumor.com/video/(\d+))'];
 
     bless($self, $class);
     $self->_prepare_parameters();
@@ -29,6 +37,7 @@ sub _parse {
     my $content;
     my $metadata = {};
     my $p = XML::Simple->new();
+    my @accum;
     my $t;
 
     $url =~ m|$pattern|;
@@ -36,12 +45,13 @@ sub _parse {
 
     $metadata->{'URL'} = $url;
     $metadata->{'ID'} = $2;
-    $metadata->{'TYPE'} = 'collegehumor';
+    $metadata->{'TYPE'} = 'video';
+    $metadata->{'SOURCE'} = $self->{'NAME'};
     $metadata->{'TITLE'} = undef;
     $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 = $self->simple_get(sprintf('http://www.collegehumor.com/moogaloop/video/%s', $2)))) {
         $self->error('Could not download XML metadata');
         return undef;
     }