2020-12-26 03:04:37 +01:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
use feature 'say';
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
2020-12-29 02:29:42 +01:00
|
|
|
use Peertube::DL::URLHandler;
|
2020-12-26 03:04:37 +01:00
|
|
|
|
2020-12-26 03:52:11 +01:00
|
|
|
die "No url passed" unless @ARGV;
|
|
|
|
|
2020-12-29 02:29:42 +01:00
|
|
|
my $download_data = Peertube::DL::URLHandler::getDownloadDataFromURL( $ARGV[0] );
|
|
|
|
my $filename = $download_data->{filename};
|
|
|
|
my $url = $download_data->{url};
|
|
|
|
my $ua = Peertube::DL::URLHandler::generateUA();
|
|
|
|
my $response = $ua->get($url);
|
|
|
|
|
|
|
|
die "Cannot retrieve video data" unless $response->is_success;
|
|
|
|
|
|
|
|
my $content = $response->decoded_content;
|
|
|
|
|
|
|
|
open my $fh, '>', $filename or die "Cannot open $filename";
|
|
|
|
$fh->print( $response->decoded_content ) or die "Cannot write to $filename";
|
|
|
|
close $fh;
|