App-get_flash_videos
view release on metacpan or search on metacpan
get_flash_videos view on Meta::CPAN
use constant REQ_INFO => <<EOF;
A required Perl module for downloading this video is not installed.
EOF
use constant FRIENDLY_FAILURE => <<EOF;
Couldn't extract Flash movie URL. This site may need specific support adding,
or fixing.
Please confirm the site is using Flash video and if you have Flash available
check that the URL really works(!).
Check for updates by running: $0 --update
If the latest version does not support this please open a bug (or
contribute a patch!) at http://code.google.com/p/get-flash-videos/
make sure you include the output with --debug enabled.
EOF
read_conf();
GetOptions(
"yes|y" => \$opt{yes},
"filename|f=s" => \$opt{filename},
"version|v" => \$opt{version},
"update|u" => \$opt{update},
"help|h" => \$opt{help},
"play|p" => \$opt{play},
"player=s" => \$opt{player},
"proxy=s" => \$opt{proxy},
"debug|d" => \$opt{debug},
"quiet|q" => \$opt{quiet},
"add-plugin=s" => \$opt{add_plugin},
"quality|r=s" => \$opt{quality},
"subtitles" => \$opt{subtitles},
) or die "Try $0 --help for more information.\n";
if($opt{version}) {
die VER_INFO;
} elsif($opt{update}) {
exit update();
} elsif($opt{help}) {
die USAGE;
} elsif($opt{add_plugin}) {
exit add_plugin($opt{add_plugin});
}
if ($opt{debug}) {
if(my @plugins = get_installed_plugins()) {
debug @plugins . " plugin" . (@plugins != 1 && "s") . " installed:";
debug "- $_" for @plugins;
} else {
debug "No plugins installed";
}
}
if($^O =~ /MSWin/i) {
$opt{filename} = Encode::decode(get_win_codepage(), $opt{filename});
binmode STDERR, ":encoding(" . get_win_codepage() . ")";
binmode STDOUT, ":encoding(" . get_win_codepage() . ")";
} else {
$opt{filename} = Encode::decode("utf-8", $opt{filename});
binmode STDERR, ":utf8";
binmode STDOUT, ":utf8";
}
my (@urls) = @ARGV;
@urls > 0 or die USAGE;
# Search string can either be quoted or unquoted (for ultimate laziness)
my $search;
if ( ((@urls == 1) and $urls[0] !~ m'\.') or
( (@urls > 1) and ! grep /^http:\/\/|^[\w\-]+\.[\w\-]+/, @urls)) {
$search = join ' ', @urls;
}
my @download_urls;
if ($search) {
if (my @results = FlashVideo::Search->search($search, 10, 20)) {
if ($opt{yes} or @results == 1) {
my $message = (@results == 1) ?
"Downloading only match for '$search': '$results[0]->{name}'" :
"Downloading first match for '$search': '$results[0]->{name}'" ;
info $message;
push @download_urls, $results[0]->{url};
}
else {
print "Search for '$search' found these results:\n";
# Need 5 chars for "[nn] ".
my $columns = get_terminal_width() - 5;
local $Text::Wrap::columns = $columns;
my $count = 1;
for my $result(@results) {
printf "[%2d] %s\n", $count, $result->{name};
if ($result->{description}) {
# Show as much of the description as will fit on at least 2
# lines in the current terminal width. (Not exact because
# Text::Wrap wraps only after whole words.)
print wrap(" ", " ",
substr($result->{description}, 0, $columns * 2)), "\n";
}
$count++;
}
print "Enter the number(s) or range (e.g. 1-3) of the videos to download " .
"(separate multiple with comma or space): ";
chomp(my $choice = <STDIN>);
$choice ||= 1;
for(split /[ ,]+/, $choice) {
if (/-/) {
my ($lower, $upper) = split /-/, $choice;
if ($upper > $lower and $upper > 0) {
push @download_urls, map { $results[$_]->{url} } $lower - 1 .. $upper - 1;
next;
}
else {
print STDERR "Search range '$_' is invalid.\n";
( run in 1.100 second using v1.01-cache-2.11-cpan-5a3173703d6 )