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