forked from sergiotarxz/Peertube-dl
Added youtube support at webpage.
This commit is contained in:
parent
3abba1edce
commit
702e427ef1
@ -16,10 +16,20 @@ get '/' => sub {
|
||||
|
||||
post '/api' => sub {
|
||||
my $c = shift;
|
||||
my $url = $c->req->json->{url}
|
||||
// ( return $c->render( text => 'Malformed request due missing url json parameter.', status => 400 ) );
|
||||
my $url = $c->req->json->{url} // (
|
||||
return $c->render(
|
||||
text => 'Malformed request due missing url json parameter.',
|
||||
status => 400
|
||||
)
|
||||
);
|
||||
my $render_returned;
|
||||
eval { $render_returned = $c->render( json => Peertube::DL::URLHandler::getDownloadDataFromURL($url) ); };
|
||||
eval {
|
||||
$render_returned = $c->render(
|
||||
json => Peertube::DL::URLHandler::getDownloadDataFromURL(
|
||||
$url, { format => 18 }
|
||||
)
|
||||
);
|
||||
};
|
||||
if ($@) {
|
||||
return $c->render( text => $@, status => 500 );
|
||||
}
|
||||
@ -28,9 +38,15 @@ post '/api' => sub {
|
||||
|
||||
post '/proxy_to_get' => sub {
|
||||
my $c = shift;
|
||||
my $url = $c->req->json->{url}
|
||||
// ( return $c->render( text => 'Malformed request due missing url json parameter.', status => 400 ) );
|
||||
die "Not supported url" unless $url =~ s/^https:\/\///r =~ /^storage\.googleapis\.com/;
|
||||
my $url = $c->req->json->{url} // (
|
||||
return $c->render(
|
||||
text => 'Malformed request due missing url json parameter.',
|
||||
status => 400
|
||||
)
|
||||
);
|
||||
die "Not supported url"
|
||||
unless ( $url =~ s/^https?:\/\///r =~ /^storage\.googleapis\.com/
|
||||
|| $url =~ s/https?:\/\///r =~ s/\/.*$//r =~ /googlevideo\.com$/ );
|
||||
my $ua = Peertube::DL::URLHandler::generateUA();
|
||||
return $c->render(
|
||||
data => $ua->get($url)->decoded_content,
|
||||
@ -38,8 +54,10 @@ post '/proxy_to_get' => sub {
|
||||
);
|
||||
};
|
||||
|
||||
push @{ app->renderer->paths }, ( Peertube::DL::getDir() . '/Peertube/DL/templates' );
|
||||
push @{ app->static->paths }, ( Peertube::DL::getDir() . '/Peertube/DL/public' );
|
||||
push @{ app->renderer->paths },
|
||||
( Peertube::DL::getDir() . '/Peertube/DL/templates' );
|
||||
push @{ app->static->paths },
|
||||
( Peertube::DL::getDir() . '/Peertube/DL/public' );
|
||||
|
||||
my $config = plugin 'Config';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user