Peertube-dl/lib/Peertube/DL/UserAgent.pm

30 lines
550 B
Perl
Raw Normal View History

2020-12-26 06:18:43 +01:00
package Peertube::DL::UserAgent;
use strict;
use warnings;
use feature 'say';
use LWP::UserAgent;
use parent 'LWP::UserAgent';
my $last_progress_time;
sub redirect_ok {
1;
}
sub progress {
my $self = shift;
my $status = shift;
my $response = shift;
if ( !defined $last_progress_time || time > $last_progress_time + 1 ) {
$last_progress_time = time;
if ( $response->isa('HTTP::Response') && $status =~ /^\d/ ) {
say $response->base . ': ' . int( $status * 100 ) . '%';
}
}
}
1;