X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=videosite-dl.pl;h=257da2d1b69a3bb01553447ec424bf40a2e19666;hb=a21902ff29384676eb0e776140a81a67f81dc8c6;hp=8b1b161ca38fe6381008271d7fe4643be98d68e6;hpb=ec82169c91789d3de1f2075b9fd8c6d99758eff5;p=videosite.git diff --git a/videosite-dl.pl b/videosite-dl.pl index 8b1b161..257da2d 100755 --- a/videosite-dl.pl +++ b/videosite-dl.pl @@ -48,6 +48,21 @@ sub ploader { return @g; } +sub connectors { + my $c = {-name => 'environment', -schemas => {}}; + + if (exists($ENV{'http_proxy'})) { + $c->{-schemas}->{'http'} = $ENV{'http_proxy'} + } + + if (exists($ENV{'https_proxy'})) { + $c->{-schemas}->{'https'} = $ENV{'https_proxy'} + } + + return ( $c ); +} + + my $hq = 0; my $ext = '.flv'; my $y; @@ -55,6 +70,10 @@ my $f; my $m; my @g; my $bp; +my $info = 0; +my $debug = 0; + +GetOptions("i" => \$info, "d" => \$debug); # This is some dark magic to find out our real base directory, # where we hope to find our plugins. @@ -69,14 +88,29 @@ unless(@g and defined($f)) { exit 1; } +foreach (@g, $f) { + $_->setio(sub { printf(@_); print("\n"); } ); + + if ($debug) { + $_->setdebug(1); + $_->setconn(\&connectors); + } +} + $f->setval('FILEPATTERN', './%3$s' . $ext); foreach (@ARGV) { foreach $y (@g) { ($m, undef) = $y->get($_); if (defined($m)) { - print("Downloading $m->{'TITLE'}\n"); - $f->get($m); + if ($info) { + foreach (keys(%{$m})) { + printf("%s: %s\n", $_, defined($m->{$_})?$m->{$_}:'(undef)'); + } + } else { + print("Downloading $m->{'TITLE'}\n"); + $f->get($m); + } } } }