X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=libvideosite.pm;h=bc41e5c136c06b39304be8b5efc436513d3ef18b;hb=88757bf7a37a953e33c37721eb086789a5e5e169;hp=52a771b38bf35ec19b389b277707582b2b291d4e;hpb=cc26109147976931511f440bbe67618b3503766d;p=videosite.git diff --git a/libvideosite.pm b/libvideosite.pm index 52a771b..bc41e5c 100644 --- a/libvideosite.pm +++ b/libvideosite.pm @@ -319,6 +319,13 @@ sub _config_has { return $b; } +sub _config_del { + my $path = shift; + + _debug("config: removing %s", join('.', @{$path})); + $remote_api->{config_del}->($path); +} + # # The _config_list_* are helper functions taking a path to a comma separated # string. The string is interpreted as a list and the action performed @@ -360,9 +367,9 @@ sub _config_list_del { } _debug("Removing %s from list %s", $item, join('.', @{$path})); - @c = map { $item ne $_ } split(/\s*,\s*/, _config_get($path)); + @c = grep { $item ne $_ } split(/\s*,\s*/, _config_get($path)); - _config_set($path, join('.', @c)); + _config_set($path, join(',', @c)); } # @@ -714,6 +721,11 @@ sub _cmd_connector { $name = lc($name); + unless($name =~ m|^[a-z]+$|) { + _io("%s is not a valid connector name (only letters are allowed)", $name); + return; + } + if (_config_list_has(['defined-connectors'], $name)) { _io("Connector already exists"); return; @@ -730,7 +742,7 @@ sub _cmd_connector { return; } - unless (_config_list_has(['defined-connectors'])) { + unless (_config_list_has(['defined-connectors'], $name)) { _io("Connector does not exist"); return; } @@ -979,11 +991,16 @@ sub check_for_link { my $g; my $m; my $p; + my $skip; + my $mode = _config_get(['mode']); - # Look if we should ignore this line + # + # If /nosave is present in the message switch to display mode, regardless + # of config setting + # if ($message =~ m,(?:\s|^)/nosave(?:\s|$),) { - return; + $mode = 'display'; } _push_output($event->{ewpf}); @@ -996,38 +1013,41 @@ sub check_for_link { ($m, $p) = $g->get($message); while (defined($m)) { _debug('Metadata: %s', Dumper($m)); + $skip = 0; if (exists($remote_api->{link_callback})) { - $remote_api->{link_callback}->($m); + $skip = $remote_api->{link_callback}->($m); } - if ('download' eq _config_get(['mode'])) { - _io( - sprintf('%s>>> %sSaving %s%%s%s %s%%s', - _colorpair('*red'), - _colorpair(), - _colorpair('*yellow'), - _colorpair(), - _colorpair('*green'), - ), - $m->{'SOURCE'}, - $m->{'TITLE'} - ); - unless($getter->get($m)) { - _io(sprintf('%s>>> FAILED', _colorpair('*red'))); + unless($skip) { + if ('download' eq $mode) { + _io( + sprintf('%s>>> %sSaving %s%%s%s %s%%s', + _colorpair('*red'), + _colorpair(), + _colorpair('*yellow'), + _colorpair(), + _colorpair('*green'), + ), + $m->{'SOURCE'}, + $m->{'TITLE'} + ); + unless($getter->get($m)) { + _io(sprintf('%s>>> FAILED', _colorpair('*red'))); + } + } elsif ('display' eq $mode) { + _io( + sprintf('%s>>> %sSaw %s%%s%s %s%%s', + _colorpair('*magenta'), + _colorpair(), + _colorpair('*yellow'), + _colorpair(), + _colorpair('*green') + ), + $m->{'SOURCE'}, + $m->{'TITLE'} + ); + } else { + _io(sprintf('%s>>> Invalid operation mode', _colorpair('*red'))); } - } elsif ('display' eq _config_get(['mode'])) { - _io( - sprintf('%s>>> %sSaw %s%%s%s %s%%s', - _colorpair('*magenta'), - _colorpair(), - _colorpair('*yellow'), - _colorpair(), - _colorpair('*green') - ), - $m->{'SOURCE'}, - $m->{'TITLE'} - ); - } else { - _io(sprintf('%s>>> Invalid operation mode', _colorpair('*red'))); } # Remove the matched part from the message and try again (there may be