From d39760ae810bf7854b5b59333461d7d75e0560f6 Mon Sep 17 00:00:00 2001 From: Ralf Ertzinger Date: Wed, 25 Aug 2010 08:38:05 +0200 Subject: [PATCH] Youtube: Enhance error check in the login process --- videosite/YouTubeGrabber.pm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/videosite/YouTubeGrabber.pm b/videosite/YouTubeGrabber.pm index b489130..556e9c7 100644 --- a/videosite/YouTubeGrabber.pm +++ b/videosite/YouTubeGrabber.pm @@ -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')) { -- 1.8.3.1