Youtube: Enhance error check in the login process
authorRalf Ertzinger <ralf@skytale.net>
Wed, 25 Aug 2010 06:38:05 +0000 (08:38 +0200)
committerRalf Ertzinger <ralf@skytale.net>
Wed, 25 Aug 2010 06:38:05 +0000 (08:38 +0200)
videosite/YouTubeGrabber.pm

index b489130..556e9c7 100644 (file)
@@ -269,16 +269,25 @@ sub __login {
 
     $self->debug('Logging in');
     $r = $ua->get('https://www.google.com/accounts/ServiceLoginAuth?service=youtube');
+    unless($r->is_success()) {
+        $self->debug("Could not get login page (make sure your LWP supports HTTPS!)");
+        return undef;
+    }
     $c = $r->decoded_content();
     $p = HTML::TokeParser->new(\$c);
     while (my $tag = $p->get_tag('input')) {
+        $self->debug("%s", Dumper($tag));
         if ($tag->[1]{name} eq 'GALX') {
             $token = $tag->[1]{value};
             last;
         }
     }
-    $self->debug("GALX = .$token");
+    $self->debug("GALX = %s", $token);
     $r = $ua->post('https://www.google.com/accounts/ServiceLoginAuth?service=youtube', { 'service' => 'youtube', 'Email' => $user, 'Passwd' => $pass, 'GALX' => $token });
+    unless($r->is_success()) {
+        $self->debug("Could not get login page (make sure your LWP supports HTTPS!)");
+        return undef;
+    }
     $c = $r -> decoded_content();
     $p = HTML::TokeParser->new(\$c);
     while (my $tag = $p->get_tag('script')) {