Peertube-dl/bin/peertube-dl

35 lines
1.1 KiB
Perl
Executable File

#!/usr/bin/env perl
use feature 'say';
use strict;
use warnings;
use Peertube::DL::UserAgent;
use Peertube::DL::Downloaders;
my $ua = Peertube::DL::UserAgent->new( timeout => 10 );
$ua->agent('Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0');
my $response = $ua->get( $ARGV[0] );
my %handlers = (
gocdn => { reg => qr/gocdn\.html#/, subr => \&Peertube::DL::Downloaders::gocdn },
animeid => { reg => qr/animeid\.to\/streaming\.php\?/, subr => \&Peertube::DL::Downloaders::animeid },
);
die "No url passed" unless @ARGV;
my $handled = 0;
for my $x ( keys %handlers ) {
if ( $response->decoded_content =~ m/$handlers{$x}{reg}/ ) {
eval { $handlers{$x}{subr}->( $ua, $response ); };
if ($@) {
say $@;
} else {
$handled = 1;
last;
}
}
}
say "The url could not be handled, post a issue on https://gitea.sergiotarxz.freemyip.com/sergiotarxz/Peertube-dl/issues telling me the url which does not allow you to download the video so I add support for it." unless $handled;