forked from sergiotarxz/Peertube-dl
Merge pull request 'tests: Adding tests to check youtube keeps the current compability.' (#25) from test/adding_youtube_integration_test into master
Reviewed-on: https://gitea.sergiotarxz.freemyip.com/sergiotarxz/Peertube-dl/pulls/25
This commit is contained in:
commit
bd2b1094e0
@ -43,6 +43,9 @@ if ( defined $download_data->{options}{list} && $download_data->{options}{list}
|
||||
say "The urls are:\n" . join "\n", @$urls;
|
||||
}
|
||||
} elsif ( defined $download_data->{options}{list_formats} && $download_data->{options}{list_formats} ) {
|
||||
say 'Listing formats available.';
|
||||
delete $download_data->{options};
|
||||
say "The available formats are: @{[Data::Dumper::Dumper $download_data]}";
|
||||
exit 0;
|
||||
} else {
|
||||
downloadVideo( $ua, $download_data );
|
||||
|
@ -67,9 +67,6 @@ sub getDownloadDataFromURL {
|
||||
die "No description." unless defined $download_data->{description};
|
||||
die "No formats available." unless defined $download_data->{formats};
|
||||
die "Formats is not a hash." unless ref $download_data->{formats} eq 'HASH';
|
||||
say "The video title is $download_data->{title}.";
|
||||
say "The video description is $download_data->{description}.";
|
||||
say "The available formats are: @{[Data::Dumper::Dumper $download_data->{formats}]}.";
|
||||
return $download_data;
|
||||
}
|
||||
}
|
||||
|
321
t-download/00-youtube.com.t
Normal file
321
t-download/00-youtube.com.t
Normal file
@ -0,0 +1,321 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Test::Most tests => 5;
|
||||
use Digest::SHA qw/sha512_hex/;
|
||||
use Data::Dumper;
|
||||
|
||||
BEGIN {
|
||||
use_ok 'Peertube::DL::URLHandler';
|
||||
}
|
||||
|
||||
## Tests WITH signatures.
|
||||
{
|
||||
my $download_data = Peertube::DL::URLHandler::getDownloadDataFromURL(
|
||||
'https://www.youtube.com/watch?v=nqc4t4029as');
|
||||
my $download_data_expected = {
|
||||
'formats' => {
|
||||
'audio_formats' => [
|
||||
{
|
||||
'mimeType' => 'audio/webm; codecs="opus"',
|
||||
'quality' => 'tiny',
|
||||
'audioSampleRate' => 48000,
|
||||
'bitrate' => 133750,
|
||||
'id' => 251
|
||||
},
|
||||
{
|
||||
'bitrate' => 67550,
|
||||
'id' => 250,
|
||||
'mimeType' => 'audio/webm; codecs="opus"',
|
||||
'quality' => 'tiny',
|
||||
'audioSampleRate' => 48000
|
||||
},
|
||||
{
|
||||
'bitrate' => 51104,
|
||||
'id' => 249,
|
||||
'mimeType' => 'audio/webm; codecs="opus"',
|
||||
'audioSampleRate' => 48000,
|
||||
'quality' => 'tiny'
|
||||
}
|
||||
],
|
||||
'video_formats' => [
|
||||
{
|
||||
'qualityLabel' => 1080,
|
||||
'mimeType' => 'video/mp4; codecs="avc1.640028"',
|
||||
'quality' => 'hd1080',
|
||||
'id' => 137,
|
||||
'bitrate' => 1610654
|
||||
},
|
||||
{
|
||||
'quality' => 'hd1080',
|
||||
'mimeType' => 'video/webm; codecs="vp9"',
|
||||
'qualityLabel' => 1080,
|
||||
'bitrate' => 1552727,
|
||||
'id' => 248
|
||||
},
|
||||
{
|
||||
'bitrate' => 1074995,
|
||||
'id' => 399,
|
||||
'mimeType' => 'video/mp4; codecs="av01.0.08M.08"',
|
||||
'qualityLabel' => 1080,
|
||||
'quality' => 'hd1080'
|
||||
},
|
||||
{
|
||||
'id' => 247,
|
||||
'bitrate' => 687059,
|
||||
'quality' => 'hd720',
|
||||
'mimeType' => 'video/webm; codecs="vp9"',
|
||||
'qualityLabel' => 720
|
||||
},
|
||||
{
|
||||
'quality' => 'hd720',
|
||||
'qualityLabel' => 720,
|
||||
'mimeType' => 'video/mp4; codecs="av01.0.05M.08"',
|
||||
'id' => 398,
|
||||
'bitrate' => 659074
|
||||
},
|
||||
{
|
||||
'mimeType' => 'video/mp4; codecs="avc1.4d401f"',
|
||||
'qualityLabel' => 720,
|
||||
'quality' => 'hd720',
|
||||
'id' => 136,
|
||||
'bitrate' => 579992
|
||||
},
|
||||
{
|
||||
'id' => 244,
|
||||
'bitrate' => 421009,
|
||||
'qualityLabel' => 480,
|
||||
'mimeType' => 'video/webm; codecs="vp9"',
|
||||
'quality' => 'large'
|
||||
},
|
||||
{
|
||||
'quality' => 'large',
|
||||
'mimeType' => 'video/mp4; codecs="av01.0.04M.08"',
|
||||
'qualityLabel' => 480,
|
||||
'id' => 397,
|
||||
'bitrate' => 385094
|
||||
},
|
||||
{
|
||||
'mimeType' => 'video/mp4; codecs="avc1.4d401e"',
|
||||
'qualityLabel' => 480,
|
||||
'quality' => 'large',
|
||||
'id' => 135,
|
||||
'bitrate' => 353336
|
||||
},
|
||||
{
|
||||
'bitrate' => 645178,
|
||||
'id' => 18,
|
||||
'mimeType' => 'video/mp4; codecs="avc1.42001E, mp4a.40.2"',
|
||||
'quality' => 'medium',
|
||||
'qualityLabel' => 360,
|
||||
'audioSampleRate' => '44100'
|
||||
},
|
||||
{
|
||||
'quality' => 'medium',
|
||||
'qualityLabel' => 360,
|
||||
'mimeType' => 'video/webm; codecs="vp9"',
|
||||
'bitrate' => 281570,
|
||||
'id' => 243
|
||||
},
|
||||
{
|
||||
'id' => 134,
|
||||
'bitrate' => 241943,
|
||||
'quality' => 'medium',
|
||||
'qualityLabel' => 360,
|
||||
'mimeType' => 'video/mp4; codecs="avc1.4d401e"'
|
||||
},
|
||||
{
|
||||
'bitrate' => 234609,
|
||||
'id' => 396,
|
||||
'quality' => 'medium',
|
||||
'qualityLabel' => 360,
|
||||
'mimeType' => 'video/mp4; codecs="av01.0.01M.08"'
|
||||
},
|
||||
{
|
||||
'mimeType' => 'video/webm; codecs="vp9"',
|
||||
'qualityLabel' => 240,
|
||||
'quality' => 'small',
|
||||
'id' => 242,
|
||||
'bitrate' => 160233
|
||||
},
|
||||
{
|
||||
'qualityLabel' => 240,
|
||||
'mimeType' => 'video/mp4; codecs="avc1.4d4015"',
|
||||
'quality' => 'small',
|
||||
'bitrate' => 130312,
|
||||
'id' => 133
|
||||
},
|
||||
{
|
||||
'id' => 395,
|
||||
'bitrate' => 121695,
|
||||
'mimeType' => 'video/mp4; codecs="av01.0.00M.08"',
|
||||
'qualityLabel' => 240,
|
||||
'quality' => 'small'
|
||||
},
|
||||
{
|
||||
'id' => 278,
|
||||
'bitrate' => 86048,
|
||||
'quality' => 'tiny',
|
||||
'qualityLabel' => 144,
|
||||
'mimeType' => 'video/webm; codecs="vp9"'
|
||||
},
|
||||
{
|
||||
'bitrate' => 77340,
|
||||
'id' => 160,
|
||||
'qualityLabel' => 144,
|
||||
'mimeType' => 'video/mp4; codecs="avc1.4d400c"',
|
||||
'quality' => 'tiny'
|
||||
},
|
||||
{
|
||||
'mimeType' => 'video/mp4; codecs="av01.0.00M.08"',
|
||||
'qualityLabel' => 144,
|
||||
'quality' => 'tiny',
|
||||
'bitrate' => 63369,
|
||||
'id' => 394
|
||||
}
|
||||
]
|
||||
},
|
||||
'options' => { 'list_formats' => 1 },
|
||||
'description' =>
|
||||
"Tras el \x{e9}xito de Zeus, Hades, Poseid\x{f3}n y Dem\x{e9}ter, hoy os traemos la canci\x{f3}n de otra de sus hermanas, \x{a1}Hestia! \x{bf}A qu\x{e9} esperas para descubrir la historia de esta diosa de la mitolog\x{ed}a griega en un nuevo Destripando la Historia?
|
||||
|
||||
\x{a1}Suscr\x{ed}bete a nuestro canal!
|
||||
http://bit.ly/pascuyrodri
|
||||
|
||||
\x{a1}Escucha esta y otras canciones en SPOTIFY!
|
||||
https://spoti.fi/2SY6zni
|
||||
|
||||
\x{a1}Consigue nuestras camisetas, chapas y l\x{e1}minas!
|
||||
https://www.destripandolahistoria.es
|
||||
*Solo con env\x{ed}o a Espa\x{f1}a peninsular.
|
||||
|
||||
\x{a1}Tambi\x{e9}n ten\x{e9}is parte de nuestro merchandising en Teespring!
|
||||
(Con env\x{ed}os internacionales)
|
||||
https://www.teespring.com/stores/destripandolahistoria
|
||||
|
||||
|
||||
\x{a1}Puedes seguir a Destripando la Historia en Facebook, Instagram y Twitter! Publicamos contenido extra como dibujos, v\x{ed}deos cantando en directo o tonter\x{ed}as absurdas, ya nos conoc\x{e9}is...
|
||||
|
||||
http://www.instagram.com/destripandolahistoria
|
||||
http://www.facebook.com/destripandolahistoria
|
||||
https://twitter.com/pascuyrodri
|
||||
|
||||
\x{a1}Hola a todos!
|
||||
\x{a1}La cuarentena no ha podido con nosotros y aqu\x{ed} ten\x{e9}is un nuevo v\x{ed}deo! Esperamos que est\x{e9}is todos bien y que lo disfrut\x{e9}is. Si hab\x{e9}is le\x{ed}do hasta aqu\x{ed}, como venganza porque Pascu ha metido una foto m\x{ed}a al principio del v\x{ed}deo, os pido que pong\x{e1}is en los comentarios: \x{201c}Pascu, baja la tapa del v\x{e1}ter\x{201d}.
|
||||
|
||||
Rodri
|
||||
|
||||
\x{a1}Recordad que pod\x{e9}is seguirnos tambi\x{e9}n en nuestras redes sociales personales!
|
||||
|
||||
http://www.instagram.com/rodrigoseptienmusic
|
||||
https://www.instagram.com/alv_pascu/
|
||||
https://twitter.com/var_Stark
|
||||
https://twitter.com/RodrigoSeptien",
|
||||
'title' => 'Hestia | Destripando la Historia'
|
||||
};
|
||||
is_deeply $download_data, $download_data_expected,
|
||||
'Testing listing formats with obfuscated signatures.';
|
||||
}
|
||||
|
||||
{
|
||||
my $download_data = Peertube::DL::URLHandler::getDownloadDataFromURL(
|
||||
'https://www.youtube.com/watch?v=nqc4t4029as', { format => 18 } );
|
||||
my $ua = Peertube::DL::URLHandler::generateUA();
|
||||
my $downloaded_video_checksum =
|
||||
sha512_hex( $ua->get( $download_data->{url} )->decoded_content );
|
||||
my $expected_checksum =
|
||||
'a59f5f1e582bd558ef4e928d7edfd942452aff5084218a3470da946d73c94f28e102773d5b19f47c6224492a82e6c7072a47aae87333bcfeda457a33626c92e7';
|
||||
is $downloaded_video_checksum, $expected_checksum,
|
||||
'Testing downloading with obfuscated signatures.';
|
||||
}
|
||||
|
||||
## WITHOUT signature.
|
||||
{
|
||||
my $expected_download_data = {
|
||||
'description' =>
|
||||
'Richard Stallman en Ecuador, cantando el temita, del free software, grabado por Julian Coccia.',
|
||||
'formats' => {
|
||||
'audio_formats' => [
|
||||
{
|
||||
'bitrate' => 139941,
|
||||
'id' => 251,
|
||||
'quality' => 'tiny',
|
||||
'audioSampleRate' => 48000,
|
||||
'mimeType' => 'audio/webm; codecs="opus"'
|
||||
},
|
||||
{
|
||||
'bitrate' => 72446,
|
||||
'id' => 250,
|
||||
'audioSampleRate' => 48000,
|
||||
'quality' => 'tiny',
|
||||
'mimeType' => 'audio/webm; codecs="opus"'
|
||||
},
|
||||
{
|
||||
'bitrate' => 55976,
|
||||
'id' => 249,
|
||||
'quality' => 'tiny',
|
||||
'audioSampleRate' => 48000,
|
||||
'mimeType' => 'audio/webm; codecs="opus"'
|
||||
}
|
||||
],
|
||||
'video_formats' => [
|
||||
{
|
||||
'id' => 18,
|
||||
'bitrate' => 367576,
|
||||
'audioSampleRate' => '44100',
|
||||
'quality' => 'small',
|
||||
'mimeType' => 'video/mp4; codecs="avc1.42001E, mp4a.40.2"',
|
||||
'qualityLabel' => 240
|
||||
},
|
||||
{
|
||||
'bitrate' => 244690,
|
||||
'id' => 133,
|
||||
'quality' => 'small',
|
||||
'qualityLabel' => 240,
|
||||
'mimeType' => 'video/mp4; codecs="avc1.4d400d"'
|
||||
},
|
||||
{
|
||||
'mimeType' => 'video/webm; codecs="vp9"',
|
||||
'quality' => 'small',
|
||||
'qualityLabel' => 240,
|
||||
'id' => 242,
|
||||
'bitrate' => 161442
|
||||
},
|
||||
{
|
||||
'bitrate' => 112818,
|
||||
'id' => 160,
|
||||
'qualityLabel' => 144,
|
||||
'quality' => 'tiny',
|
||||
'mimeType' => 'video/mp4; codecs="avc1.4d400c"'
|
||||
},
|
||||
{
|
||||
'mimeType' => 'video/webm; codecs="vp9"',
|
||||
'quality' => 'tiny',
|
||||
'qualityLabel' => 144,
|
||||
'id' => 278,
|
||||
'bitrate' => 70172
|
||||
}
|
||||
]
|
||||
},
|
||||
'title' => 'Richard Stallman Free software Song'
|
||||
};
|
||||
my $download_data = Peertube::DL::URLHandler::getDownloadDataFromURL(
|
||||
'https://www.youtube.com/watch?v=9sJUDx7iEJw');
|
||||
delete $download_data->{options};
|
||||
is_deeply( $download_data, $expected_download_data,
|
||||
'Testing listing signatures without obfuscated signatures.' );
|
||||
}
|
||||
|
||||
{
|
||||
my $download_data = Peertube::DL::URLHandler::getDownloadDataFromURL(
|
||||
'https://www.youtube.com/watch?v=9sJUDx7iEJw', { format => 18 } );
|
||||
my $ua = Peertube::DL::URLHandler::generateUA();
|
||||
my $downloaded_video_checksum =
|
||||
sha512_hex( $ua->get( $download_data->{url} )->decoded_content );
|
||||
my $expected_checksum =
|
||||
'16343940a5473a2ac3f485d11b1e920c974a4f506859368f669ad8af4a30b885b41c8ba301364997fc2ae50bb41d9d167768bcd9bfb4a51d76767ec165b744da';
|
||||
is $downloaded_video_checksum, $expected_checksum,
|
||||
'Testing downloading without obfuscated signatures.';
|
||||
}
|
Loading…
Reference in New Issue
Block a user