Reduccing verbosity.

This commit is contained in:
sergiotarxz 2021-01-13 09:22:00 +01:00
parent 7d22cfe5c4
commit c072be6652
Signed by: sergiotarxz
GPG Key ID: E5903508B6510AC2

View File

@ -31,14 +31,6 @@ sub youtube {
my $microformat =
$ytInitialPlayerResponse->{microformat}{playerMicroformatRenderer};
$ytInitialPlayerResponse = $ytInitialPlayerResponse->{streamingData};
say Data::Dumper::Dumper [
scalar @{ $ytInitialPlayerResponse->{adaptiveFormats} }
? @{ $ytInitialPlayerResponse->{adaptiveFormats} }
: (),
scalar @{ $ytInitialPlayerResponse->{formats} }
? @{ $ytInitialPlayerResponse->{formats} }
: ()
];
if ( defined $options->{format} ) {
my $format = $options->{format};
@ -51,7 +43,6 @@ sub youtube {
: ()
);
my $mime_type = $format->{mimeType} =~ s/;.*$//r;
say $mime_type;
my $extension = $mime_type =~ s/^.*?\///r =~ s/;.*$//r;
if ( defined $format->{url} ) {
return {
@ -73,8 +64,6 @@ sub youtube {
$url_data
};
say Data::Dumper::Dumper $url_data;
my ($player_url) =
$response->decoded_content =~ m/"jsUrl"\s*:\s*("[^"]+")/;
$player_url = JSON::from_json( $player_url, { allow_nonref => 1 } );
@ -109,21 +98,12 @@ sub youtube {
my $signature =
$js->callJSFunction( $function_name_regen_sig, $url_data->{s} );
my $url = $url_data->{url} . "&sig=${signature}";
say Data::Dumper::Dumper $format;
say $url;
return {
url => $url,
filename => $microformat->{title}{simpleText} . '.' . $extension,
};
} else {
say Data::Dumper::Dumper [
scalar @{ $ytInitialPlayerResponse->{adaptiveFormats} }
? @{ $ytInitialPlayerResponse->{adaptiveFormats} }
: (),
scalar @{ $ytInitialPlayerResponse->{formats} }
? @{ $ytInitialPlayerResponse->{formats} }
: ()
];
my @formats = map {
{
id => $_->{itag},
@ -135,7 +115,7 @@ sub youtube {
),
(
( defined $_->{qualityLabel} )
? ( qualityLabel => int( $_->{qualityLabel} ) )
? ( qualityLabel => $_->{qualityLabel} =~ s/p$//r )
: ()
),
(