forked from sergiotarxz/Peertube-dl
30 lines
550 B
Perl
30 lines
550 B
Perl
|
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;
|