From: Ralf Ertzinger Date: Sat, 5 Jan 2008 23:00:30 +0000 (+0100) Subject: - Fix some bugs in the XML config handling X-Git-Url: https://git.camperquake.de/gitweb.cgi?p=videosite.git;a=commitdiff_plain;h=7d7ff7b6405f55adf3e083808da57b6bc6a31312 - Fix some bugs in the XML config handling --- diff --git a/videosite.pl b/videosite.pl index 0a8ad3f..7803fa3 100644 --- a/videosite.pl +++ b/videosite.pl @@ -97,7 +97,7 @@ sub check_for_link { sub cmd_save { open(CONF, '>'.$conffile); - print CONF XML::Simple::XMLout($conf, KeepRoot => 1, KeyAttr => ['module', 'key']); + print CONF XML::Simple::XMLout($conf, KeepRoot => 1, KeyAttr => {'config' => 'module', 'option' => 'key'}); close(CONF); } @@ -231,7 +231,7 @@ sub init_videosite { my $p; - unless(-r $conffile && defined($conf = XML::Simple::XMLin($conffile, ForceArray => ['config', 'option'], KeepRoot => 1, KeyAttr => ['module', 'key']))) { + unless(-r $conffile && defined($conf = XML::Simple::XMLin($conffile, ForceArray => ['config', 'option'], KeepRoot => 1, KeyAttr => {'config' => 'module', 'option' => 'key'}))) { # No config, start with an empty one write_debug(undef, 'No config found, using defaults'); $conf = { 'videosite' => { 'getter' => '' }}; diff --git a/videosite/Base.pm b/videosite/Base.pm index 5aa8eae..939e203 100644 --- a/videosite/Base.pm +++ b/videosite/Base.pm @@ -37,6 +37,8 @@ sub mergeconfig { my $c = shift; my $o; + return $self->{'_CONFIG'} unless defined($c); + foreach $o (keys(%{$c->{'option'}})) { if (exists($self->{'_CONFIG'}->{'option'}->{$o})) { $self->{'_CONFIG'}->{'option'}->{$o}->{'content'} = $c->{'option'}->{$o}->{'content'}; @@ -50,8 +52,7 @@ sub _prepare_parameters { my $self = shift; my $p; - $self->{'_CONFIG'} = { 'module' => $self->{'NAME'}, - 'option' => {}}; + $self->{'_CONFIG'} = {'option' => {}}; foreach $p (keys(%{$self->{'_PARAMS'}})) { $self->{'_CONFIG'}->{'option'}->{$p}->{'content'} = $self->{'_PARAMS'}->{$p}->[0]; diff --git a/videosite/DailyMotionGrabber.pm b/videosite/DailyMotionGrabber.pm index 5dae65d..081b4b4 100644 --- a/videosite/DailyMotionGrabber.pm +++ b/videosite/DailyMotionGrabber.pm @@ -23,6 +23,8 @@ sub new { bless($self, $class); + $self->_prepare_parameters(); + return $self; } diff --git a/videosite/MetaCafeGrabber.pm b/videosite/MetaCafeGrabber.pm index c960ca9..fe68855 100644 --- a/videosite/MetaCafeGrabber.pm +++ b/videosite/MetaCafeGrabber.pm @@ -23,6 +23,8 @@ sub new { bless($self, $class); + $self->_prepare_parameters(); + return $self; }