App-Photobear

 view release on metacpan or  search on metacpan

bin/curly  view on Meta::CPAN

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
      
    # 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

125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
      
    # 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

175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
    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.370 second using v1.01-cache-2.11-cpan-00829025b61 )