Peertube-dl/bin/peertube-dl

25 lines
659 B
Plaintext
Raw Normal View History

2020-12-26 03:04:37 +01:00
#!/usr/bin/env perl
use feature 'say';
use strict;
use warnings;
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;
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;