Peertube-dl/bin/peertube-dl

35 lines
1.1 KiB
Plaintext
Raw Normal View History

2020-12-26 03:04:37 +01:00
#!/usr/bin/env perl
use feature 'say';
use strict;
use warnings;
2020-12-26 06:18:43 +01:00
use Peertube::DL::UserAgent;
use Peertube::DL::Downloaders;
2020-12-26 03:04:37 +01:00
2020-12-26 06:18:43 +01:00
my $ua = Peertube::DL::UserAgent->new( timeout => 10 );
2020-12-26 03:04:37 +01:00
$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 = (
2020-12-26 06:18:43 +01:00
gocdn => { reg => qr/gocdn\.html#/, subr => \&Peertube::DL::Downloaders::gocdn },
animeid => { reg => qr/animeid\.to\/streaming\.php\?/, subr => \&Peertube::DL::Downloaders::animeid },
2020-12-26 03:04:37 +01:00
);
2020-12-26 03:52:11 +01:00
die "No url passed" unless @ARGV;
my $handled = 0;
2020-12-26 03:04:37 +01:00
for my $x ( keys %handlers ) {
if ( $response->decoded_content =~ m/$handlers{$x}{reg}/ ) {
eval { $handlers{$x}{subr}->( $ua, $response ); };
if ($@) {
say $@;
} else {
$handled = 1;
2020-12-26 06:18:43 +01:00
last;
2020-12-26 03:04:37 +01:00
}
}
}
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;