App-Photobear
view release on metacpan or search on metacpan
# Send the initial GET request
my $response = $ua->get($url);
# Follow redirects if any
while ($response->is_redirect) {
my $redirect_url = $response->header('Location');
$response = $ua->get($redirect_url);
}
say STDERR "[DEBUG] LWP::UserAgent Response code: ", $response->code if $verbose;
return $response->decoded_content;
};
if ($@) {
# Fallback to system curl command
eval {
$output = `curl --silent -L $url`;
say STDERR "[DEBUG] used curl: ", $output if $verbose;
return $output;
};
if ($@) {
lib/App/Photobear.pm view on Meta::CPAN
# Send the initial GET request
my $response = $ua->get($url);
# Follow redirects if any
while ($response->is_redirect) {
my $redirect_url = $response->header('Location');
$response = $ua->get($redirect_url);
}
return $response->decoded_content;
};
if ($@) {
# Fallback to system curl command
eval {
my $output = `curl --silent -L $url`;
return $output;
};
if ($@) {
die "Can't get content of $url: $@";
lib/App/Photobear.pm view on Meta::CPAN
my $output = $ENV{'DEBUG'} ? $TEST_ANSWER : `$cmd`;
if ($? == -1) {
Carp::croak("[photobear]", "Failed to execute: $!\n");
} elsif ($? & 127) {
Carp::croak("[photobear]", sprintf("Child died with signal %d, %s coredump\n"),
($? & 127), ($? & 128) ? 'with' : 'without');
} elsif ($? >> 8) {
Carp::croak("[photobear]", sprintf("Child exited with value %d\n", $? >> 8));
}
my $decoded_content = decode_json($output);
return $decoded_content;
}
sub download {
my ($url, $dest) = @_;
# Use curl
my $cmd = qq(curl -L -o "$dest" "$url");#
if ($TESTMODE) {
return 1;
( run in 0.235 second using v1.01-cache-2.11-cpan-00829025b61 )