Permalink
Browse files

New -i switch to print info

For other scripts to use in extracting title, filename, length,
and possibly other information.
  • Loading branch information...
1 parent c967545 commit e9fba768833b5c109a82f883fbd771720e071fff @singpolyma committed May 3, 2010
Showing with 23 additions and 0 deletions.
  1. +23 −0 get_flash_videos
View
@@ -65,6 +65,7 @@ BEGIN {
quiet => 0,
quality => "high",
subtitles => 0,
+ info => 0
);
}
@@ -94,6 +95,7 @@ Options:
-u --update Update to latest version.
-v --version Print version.
-y --yes Say yes to any questions (don't prompt for any information).
+ -i --info Print out info about video instead of downloading.
EOF
@@ -133,6 +135,7 @@ GetOptions(
"add-plugin=s" => \$opt{add_plugin},
"quality|r=s" => \$opt{quality},
"subtitles" => \$opt{subtitles},
+ "info|i" => \$opt{info},
) or die "Try $0 --help for more information.\n";
if($opt{version}) {
@@ -336,6 +339,26 @@ sub download {
my $save_as = $opt{filename} || $suggested_filename;
+ # Print info instead of downloading
+ if($opt{info}) {
+ print "Filename: " . ($save_as || $actual_url->{flv}) . "\n";
+ $_ = $suggested_filename || $actual_url->{flv};
+ s/_/ /g;
+ s/\.[^\.]*$//;
+ print "Title: " . $_ . "\n";
+ print "Content-Location: ";
+ if(ref($actual_url) eq 'HASH') {
+ print $actual_url->{rtmp} . "\n";
+ } else {
+ print $actual_url . "\n";
+ $browser->head($actual_url);
+ if($browser->response->header('Content-Length')) {
+ print "Content-Length: " . $browser->response->header('Content-Length') . "\n";
+ }
+ }
+ exit;
+ }
+
my $action = $opt{play} ? "play" : "download";
for my $data((ref($actual_url) eq 'ARRAY' ? @$actual_url : $actual_url)) {

0 comments on commit e9fba76

Please sign in to comment.