From 644d34311f24a4bd3ae345a5e0a6e0761fd05ab5 Mon Sep 17 00:00:00 2001 From: legatvs Date: Thu, 4 Nov 2010 23:32:34 +0200 Subject: [PATCH] add --format help,list --- bin/clive | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/bin/clive b/bin/clive index 1f67cb5..172001d 100755 --- a/bin/clive +++ b/bin/clive @@ -93,6 +93,7 @@ sub init { # Check --quvi. Carp::croak "error: specify path to quvi(1) command with --quvi" unless $config{quvi}; + check_format (); # Check --get-with. Carp::croak "error: specify path to a download command with --get-with\n" @@ -313,6 +314,41 @@ sub apply_regexp { exit 1; } +sub check_format { + if ($config{format} eq "help") { +print +"Usage: + --format arg get format arg + --format list list websites and supported formats + --format list arg match arg to websites, list formats for matches +Examples: + --format webm_480p get format webm_480p (youtube) + --format list youtube list youtube formats + --format list dailym list dailym(otion) formats +"; + exit 0; + } + elsif ($config{format} eq "list") { + my $q = (split /\s+/, $config{quvi})[0]; # Improve this. + my %h; + foreach (qx/$q --support/) { + my ($k,$v) = split /\s+/, $_; + $h{$k} = $v; + } + # -f list + if (scalar @ARGV > 0) { + foreach (sort keys %h) + { print "$_:\n $h{$_}\n" if $_ =~ /$ARGV[0]/; } + exit 0; + } + # -f list + else { + print "$_:\n $h{$_}\n\n" foreach sort keys %h; + exit 0; + } + } +} + sub print_help { require Pod::Usage; Pod::Usage::pod2usage (-exitstatus=>0, -verbose=>1); -- 2.11.4.GIT