Automatically add cookies gathered during grabbing to the metadata
authorRalf Ertzinger <ralf@skytale.net>
Sat, 11 Feb 2012 17:42:35 +0000 (18:42 +0100)
committerRalf Ertzinger <ralf@skytale.net>
Sat, 11 Feb 2012 17:42:35 +0000 (18:42 +0100)
videosite/Base.pm
videosite/GrabberBase.pm

index bc38468..f6108f6 100644 (file)
@@ -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;
index e354bc9..b31d934 100644 (file)
@@ -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;
         }
     }