-# This is some dark magic to find out our real base directory,
-# where we hope to find our plugins.
-$bp = File::Spec->catdir(dirname(realpath($0)), 'videosite');
-unshift(@INC, dirname(realpath($0)));
-
-@g = ploader($bp, '.*Grabber\.pm$', 'grabber');
-($f) = ploader($bp, '^FileGetter\.pm$', 'getter');
-
-unless(@g and defined($f)) {
- print("No plugins could be loaded\n");
- exit 1;
+push(@INC, dirname(realpath($0)));
+load 'libvideosite';
+
+unless(libvideosite::register_api({
+ config_init => sub {},
+ config_save => sub {},
+ config_get => sub { return $config{join(".", @{$_[0]})} },
+ config_set => sub { $config{join(".", @{$_[0]})} = $_[1] },
+ config_has => sub { exists($config{join(".", @{$_[0]})}) },
+ config_del => sub { delete($config{join(".", @{$_[0]})}) },
+ link_callback => \&link_callback,
+ _debug => sub { return $debug },
+})) {
+ die("Error registering API: $libvideosite::error");