git://git.camperquake.de
/
videosite.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Convert to use of a json style config file
[videosite.git]
/
videosite
/
Base.pm
diff --git
a/videosite/Base.pm
b/videosite/Base.pm
index
5381911
..
f6108f6
100644
(file)
--- a/
videosite/Base.pm
+++ b/
videosite/Base.pm
@@
-12,8
+12,8
@@
sub new {
my $class = shift;
my $self = {'_DEBUG' => 0,
'_OUT' => sub {printf(@_)},
my $class = shift;
my $self = {'_DEBUG' => 0,
'_OUT' => sub {printf(@_)},
- '_CONNECTORS' => sub { return ({
-name
=> 'direct',
-
-schemas
=> {} }) },
+ '_CONNECTORS' => sub { return ({
'name'
=> 'direct',
+
'schemas'
=> {} }) },
'_CONNECTOR' => undef,
};
'_CONNECTOR' => undef,
};
@@
-181,13
+181,17
@@
sub ua {
my $self = shift;
my $ua;
my $self = shift;
my $ua;
- $ua = LWP::UserAgent->new('agent' => 'Mozilla/5.0', 'cookie_jar' => HTTP::Cookies->new);
+ $ua = LWP::UserAgent->new(
+ 'agent' => 'Mozilla/5.0',
+ 'cookie_jar' => HTTP::Cookies->new,
+ 'timeout' => 15,
+ );
# Remove a currently defined HTTPS proxy. See below for a longer explanation.
delete($ENV{'HTTPS_PROXY'});
if (defined($self->{'_CONNECTOR'})) {
# Remove a currently defined HTTPS proxy. See below for a longer explanation.
delete($ENV{'HTTPS_PROXY'});
if (defined($self->{'_CONNECTOR'})) {
- my $schemas = $self->{'_CONNECTOR'}->{
-schemas
};
+ my $schemas = $self->{'_CONNECTOR'}->{
'schemas'
};
foreach (keys(%{$schemas})) {
$self->debug("Adding schema %s with proxy %s", $_, $schemas->{$_});
if ($_ eq 'https') {
foreach (keys(%{$schemas})) {
$self->debug("Adding schema %s with proxy %s", $_, $schemas->{$_});
if ($_ eq 'https') {
@@
-217,9
+221,28
@@
sub ua {
}
}
}
}
+ $self->{_CACHED_UA} = $ua;
+
return $ua;
}
return $ua;
}
+sub _cached_ua {
+ my $self = shift;
+
+ return $self->{_CACHED_UA};
+}
+
+sub simple_get {
+ my $self = shift;
+ my $url = shift;
+ my $ua = shift || $self->ua();
+ my $r;
+
+ $r = $ua->get($url);
+ return $r->decoded_content() if $r->is_success();
+ return undef;
+}
+
sub decode_hexurl {
my $self = shift;
my $d = shift;
sub decode_hexurl {
my $self = shift;
my $d = shift;