Replace use of LWP::Simple in all grabbers by $self->simple_get()
[videosite.git] / videosite / RedTubeGrabber.pm
index d461c45..4e05dfd 100644 (file)
@@ -11,8 +11,6 @@ package videosite::RedTubeGrabber;
 use videosite::GrabberBase;
 @ISA = qw(videosite::GrabberBase);
 
-use LWP::UserAgent;
-use HTTP::Cookies;
 use HTML::TokeParser;
 use Data::Dumper;
 
@@ -72,8 +70,7 @@ sub _parse {
     my $self = shift;
     my $url = shift;
     my $pattern = shift;
-    my $jar = HTTP::Cookies->new();
-    my $ua = LWP::UserAgent->new('agent' => 'Mozilla/5.0');
+    my $ua = $self->ua();
     my $content;
     my $metadata = {};
     my $p;
@@ -92,17 +89,13 @@ sub _parse {
     $metadata->{'DLURL'} = undef;
 
     # Set the cookies necessary to get the video data
-    $jar->set_cookie(undef, 'pp', '1', '/', '.redtube.com');
-    $ua->cookie_jar($jar);
+    $ua->cookie_jar->set_cookie(undef, 'pp', '1', '/', '.redtube.com');
 
-    unless(defined($r = $ua->get(sprintf("http://www.redtube.com/%s", $2)))) {
+    unless(defined($content = $self->simple_get(sprintf("http://www.redtube.com/%s", $2), $ua))) {
         $self->error('Could not download page');
         return undef;
     }
 
-    # Get the site to extract the title
-    $content = $r->decoded_content();
-
     $p = HTML::TokeParser->new(\$content);
 
     # Look for the title