From 1bc44dd403d1b6430a94adf9c6050d396bd89463 Mon Sep 17 00:00:00 2001 From: Ralf Ertzinger Date: Tue, 30 Apr 2013 20:41:49 +0200 Subject: [PATCH] libvideosite: Allow skipping of action depending on return value of link_callback --- libvideosite.pm | 62 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/libvideosite.pm b/libvideosite.pm index b53673c..da5aefa 100644 --- a/libvideosite.pm +++ b/libvideosite.pm @@ -979,6 +979,7 @@ sub check_for_link { my $g; my $m; my $p; + my $skip; # Look if we should ignore this line @@ -996,38 +997,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 _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'))); + } + } 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'))); } - } 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 -- 1.8.3.1