This file is indexed.

/usr/bin/youtube-download is in libwww-youtube-download-perl 0.40-1.

This file is owned by root:root, with mode 0o755.

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
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/usr/bin/perl

eval 'exec /usr/bin/perl  -S $0 ${1+"$@"}'
    if 0; # not running under some shell
use strict;
use warnings;
use Getopt::Long qw(GetOptions :config bundling);
use Pod::Usage qw(pod2usage);
use WWW::YouTube::Download;
use Encode qw(find_encoding decode_utf8);
use Time::HiRes;
use Term::ANSIColor qw(colored);

$ENV{ANSI_COLORS_DISABLED} = 1 if $^O eq 'MSWin32';

my $encode    = 'utf8';
my $overwrite = 0;
my $verbose   = 1;
my $interval  = 1; # sec
GetOptions(
    'o|output=s'   => \my $output,
    'F|fmt=i',     => \my $fmt,
    'v|verbose!'   => \$verbose,
    'i|interval=i' => \$interval,
    'e|encode=s'   => \$encode,
    'f|force!'     => \$overwrite,
    'q|quiet!'     => sub { $verbose = 0 },
    'h|help'       => sub { help() },
    'm|man'        => sub { pod2usage(-verbose => 2) },
    'V|version!'   => sub { show_version() },
) or help();
challeng_load_argv_from_fh() unless @ARGV;
help() unless @ARGV;

my $encoder = find_encoding($encode) or throw("not supported encoding: $encode");
$output = $encoder->decode($output) if $output;

my $client = WWW::YouTube::Download->new;

main: {
    while (@ARGV) {
        my $video_id = shift @ARGV;
        my $meta_data = $client->prepare_download($video_id);
        chatty("--> Working on $meta_data->{video_id}");
        if ($fmt && !$client->_is_supported_fmt($video_id, $fmt)) {
            throw("[$meta_data->{video_id}] this video has not supported fmt: $fmt");
        }

        # multibyte fixes
        my $filename = $client->_format_filename($output, {
            video_id => $meta_data->{video_id},
            title    => decode_utf8($meta_data->{title}),
            suffix   => $meta_data->{suffix},
        });
        $filename = filename_normalize($filename);
        $filename = $encoder->encode($filename, sub { sprintf 'U+%x', shift });

        eval {
            $client->download($video_id, {
                filename  => $filename,
                fmt       => $fmt,
                verbose   => $verbose,
                overwrite => $overwrite,
            });
        };
        throw("[$meta_data->{video_id}] $@") if $@;
        chatty(colored ['green'], 'Download successfully!');

        Time::HiRes::sleep($interval) if @ARGV;
    }
}

exit;

sub challeng_load_argv_from_fh {
    return unless $0 ne '-' && !-t STDIN;

    # e.g. $ youtube-download < video_list
    while (defined (my $line = <STDIN>)) {
        chomp $line;
        $line =~ s/#.*$//;       # comment
        $line =~ s/^\s+|\s+$//g; # trim spaces
        push @ARGV, $line;
    }
}

sub filename_normalize {
    my $filename = shift;
    $filename =~ s#[[:cntrl:]]##smg;          # remove all control characters
    $filename =~ s#^\s+|\s+$##g;              # trim spaces
    $filename =~ s#^\.+##;                    # remove multiple leading dots
    $filename =~ tr#"/\\:*?<>|#'\-\-\-_____#; # NTFS and FAT unsupported characters
    return $filename;
}

sub throw {
    die colored(['red'], 'ERROR: ', @_), "\n";
}

sub chatty {
    print @_, "\n";
}

sub show_version {
    print "youtube-download (WWW::YouTube::Download) version $WWW::YouTube::Download::VERSION\n";
    exit;
}

sub help {
    print << 'HELP';
Usage:
    youtube-download [options] video_id_or_video_url ...

Options:
    -o, --output        Output filename, supports `{$value}` format
    -e, --encode        File system encoding (e.g. cp932)
    -F, --fmt           Video quality (SEE ALSO wikipedia)
    -f, --force         Force overwrite output file
    -i, --interval      Download interval
    -v, --verbose       Turns on chatty output (defult: enable)
    -q, --quiet         Turns off progress
    -h, --help          Display help
    -m, --man           Display man page
    -V, --version       Display version

supported `{$value}` format are:
    {video_id} / {title} / {fmt} / {suffix}

    Example:
        $ youtube-download -o "[{video_id}] {title}.{suffix}"

HELP
    exit 1;
}

__END__

=head1 NAME

youtube-download - Download video(s) from YouTube

=head1 SYNOPSIS

  $ youtube-download bT8yLWy4B5w
  $ youtube-download http://www.youtube.com/watch?v=bT8yLWy4B5w
  $ youtube-download < video_list_file

=head1 OPTIONS

=over

=item -o, --output

output filename, supports `{$value}` format (defult: {video_id}.{suffix})

=item -i, --interval

Download interval (defult: 1 (sec))

=item -e, --encode

File system encoding (default: utf8)

=item -f, --force

Force overwrite output file (defult: disabled)

=item -F, --fmt

Video quality (SEE ALSO wikipedia)

=item -v, --verbose

Truns on chatty output (defult: enableed)

=item -q, --quiet

Truns off the most output

=item -h, --help

Display help

=item -m, --man

Display help page

=item -V, --version

Display version

=back

=head2 supported `{$value}` format

{video_id} / {title} / {fmt} / {suffix} / {resolution}

  Example:
  $ youtube-download -o "[{video_id}] {title}.{suffix}"

=head1 AUTHOR

Yuji Shiamda (xaicron)