From: Ralf Ertzinger Date: Sat, 11 Feb 2012 17:42:35 +0000 (+0100) Subject: Automatically add cookies gathered during grabbing to the metadata X-Git-Url: https://git.camperquake.de/gitweb.cgi?p=videosite.git;a=commitdiff_plain;h=a0c66a780bc2f652f32672303f336faafb23b911 Automatically add cookies gathered during grabbing to the metadata --- diff --git a/videosite/Base.pm b/videosite/Base.pm index bc38468..f6108f6 100644 --- a/videosite/Base.pm +++ b/videosite/Base.pm @@ -221,9 +221,17 @@ sub ua { } } + $self->{_CACHED_UA} = $ua; + return $ua; } +sub _cached_ua { + my $self = shift; + + return $self->{_CACHED_UA}; +} + sub simple_get { my $self = shift; my $url = shift; diff --git a/videosite/GrabberBase.pm b/videosite/GrabberBase.pm index e354bc9..b31d934 100644 --- a/videosite/GrabberBase.pm +++ b/videosite/GrabberBase.pm @@ -3,6 +3,8 @@ package videosite::GrabberBase; use videosite::Base; +use MIME::Base64; +use Data::Dumper; @ISA = qw(videosite::Base); use strict; @@ -40,6 +42,14 @@ sub get($$) { last; } } + if (defined($res)) { + print Dumper($res); + print Dumper($self->_cached_ua()); + if (defined($self->_cached_ua())) { + $res->{COOKIES} = encode_base64("#LWP-Cookies-1.0\n" . $self->_cached_ua()->cookie_jar->as_string(), ""); + } + } + return wantarray?($res, $pattern):$res; } }