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);
60 GetOptions("i" => \$info);
62 # This is some dark magic to find out our real base directory,
63 # where we hope to find our plugins.
64 $bp = File::Spec->catdir(dirname(realpath($0)), 'videosite');
65 unshift(@INC, dirname(realpath($0)));
67 @g = ploader($bp, '.*Grabber\.pm$', 'grabber');
68 ($f) = ploader($bp, '^FileGetter\.pm$', 'getter');
70 unless(@g and defined($f)) {
71 print("No plugins could be loaded\n");
75 $f->setval('FILEPATTERN', './%3$s' . $ext);
79 ($m, undef) = $y->get($_);
82 foreach (keys(%{$m})) {
83 printf("%s: %s\n", $_, defined($m->{$_})?$m->{$_}:'(undef)');
86 print("Downloading $m->{'TITLE'}\n");