21 opendir(D, $dir) || return ();
22 @list = grep {/$pattern/ && -f File::Spec->catfile($dir, $_) } readdir(D);
27 eval qq{ require videosite::$p; };
29 print("Failed to load plugin: $@");
33 $g = eval qq{ videosite::$p->new();};
35 print("Failed to instanciate: $@");
40 if ($type eq $g->{'TYPE'}) {
43 printf('%s has wrong type (got %s, expected %s)', $p, $g->{'TYPE'}, $type);
52 my $c = {-name => 'environment', -schemas => {}};
54 if (exists($ENV{'http_proxy'})) {
55 $c->{-schemas}->{'http'} = $ENV{'http_proxy'}
58 if (exists($ENV{'https_proxy'})) {
59 $c->{-schemas}->{'https'} = $ENV{'https_proxy'}
76 GetOptions("i" => \$info, "d" => \$debug);
78 # This is some dark magic to find out our real base directory,
79 # where we hope to find our plugins.
80 $bp = File::Spec->catdir(dirname(realpath($0)), 'videosite');
81 unshift(@INC, dirname(realpath($0)));
83 @g = ploader($bp, '.*Grabber\.pm$', 'grabber');
84 ($f) = ploader($bp, '^FileGetter\.pm$', 'getter');
86 unless(@g and defined($f)) {
87 print("No plugins could be loaded\n");
92 $_->setio(sub { printf(@_); print("\n"); } );
96 $_->setconn(\&connectors);
100 $f->setval('FILEPATTERN', './%3$s' . $ext);
104 ($m, undef) = $y->get($_);
107 foreach (keys(%{$m})) {
108 printf("%s: %s\n", $_, defined($m->{$_})?$m->{$_}:'(undef)');
111 print("Downloading $m->{'TITLE'}\n");