From ddd64fb5bd2c9a86670b779551029ba4448854dc Mon Sep 17 00:00:00 2001 From: Alexandre Morignot <erdnaxeli@cervoi.se> Date: Sun, 10 May 2015 13:50:39 +0200 Subject: [PATCH] [sites/parser] indicate new insertion --- lib/sites/parser.pm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/sites/parser.pm b/lib/sites/parser.pm index 8e72e44..ff95bf8 100644 --- a/lib/sites/parser.pm +++ b/lib/sites/parser.pm @@ -60,6 +60,9 @@ sub parse { # if we get a new content, we must save it if (%content) { + # we assume it's a new content + my $new = 1; + if ($debug) { $log->debug($content{'url'}); } @@ -75,6 +78,8 @@ sub parse { $content{'author'}, $content{'title'}, $content{'duration'}); }; if ($@) { + # seems to be already present in database + $new = 0; $log->error("Couldn't finish transaction: " . $@); } } @@ -117,7 +122,12 @@ sub parse { $dbh->commit; # message sur irc - $content{'id'} = $id; + if ($new) { + $content{'id'} = '+'.$id; + } + else { + $content{'id'} = $id; + } $content{'tags'} = \@tags; delete $content{'url'}; $irc->yield(privmsg => $chan => utils::print::print(\%content)); -- GitLab