/usr/share/doc/libwww-youtube-download-perl/examples/menu.pl is in libwww-youtube-download-perl 0.58-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | use strict;
use warnings;
use WWW::YouTube::Download;
my $url = shift || 'http://www.youtube.com/watch?v=w1IJiAXjj7k';
my $client = WWW::YouTube::Download->new();
my $data = $client->prepare_download($url);
my $umap = $data->{video_url_map};
my @alternatives = @{$umap}{sort { $a <=> $b } keys %$umap};
$|++;
my $choice;
while (!defined $choice) {
print {*STDOUT} "Available choices:\n";
for my $alt (@alternatives) {
printf {*STDOUT} "%3d - %4s - resolution %s\n",
@{$alt}{qw< fmt suffix resolution >};
}
print {*STDOUT} "Your choice: ";
(my $input = <STDIN>) =~ s/\s+//gmxs;
if (($input =~ m{^(?: 0 | [1-9]\d*)$}mxs) && exists $umap->{$input}) {
$choice = $input;
}
else {
print {*STDOUT} "Invalid choice\n\n";
}
} ## end while (!defined $choice)
# Ready to download
my $filename = "$data->{video_id}.$umap->{$choice}{suffix}";
$client->download($url, {fmt => $choice, filename => $filename});
print "saved '$filename'\n";
|