From 397042ddaf1a1d87769930d606e5e002bf028209 Mon Sep 17 00:00:00 2001 From: Alexandre Morignot <amorignot@meilleursagents.com> Date: Tue, 25 Jul 2023 22:39:55 +0200 Subject: [PATCH] chore(sites): don't return the matched url, we don't use it --- PlayBot/sessions/irc.pm | 2 +- PlayBot/sites.pm | 19 ++++--------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/PlayBot/sessions/irc.pm b/PlayBot/sessions/irc.pm index f6e5a75..c0f9b53 100644 --- a/PlayBot/sessions/irc.pm +++ b/PlayBot/sessions/irc.pm @@ -265,7 +265,7 @@ sub on_speak { my %content; # first we check for url - my @processed_str = PlayBot::sites::parse(@args); + PlayBot::sites::parse(@args); # and we check for command my $cmd = ( split /\s/, $msg )[0]; diff --git a/PlayBot/sites.pm b/PlayBot/sites.pm index 1b09c2c..57eff84 100644 --- a/PlayBot/sites.pm +++ b/PlayBot/sites.pm @@ -30,14 +30,13 @@ sub external_parse { die "Error"; } - my ( $matched_url, $external_id, $url, $title, $author, $duration ) = + my ( $external_id, $url, $title, $author, $duration ) = split( /\n/, $content ); return ( author => $author, external_id => $external_id, duration => $duration, - matched_url => $matched_url, playlist => 0, site => 'soundcloud', title => $title, @@ -53,9 +52,6 @@ sub parse { my %content; - my $matching_url; - my @matching_tags; - eval { %content = external_parse($msg) }; if ($@) { # parsing @@ -67,7 +63,6 @@ sub parse { my @args; if ( @args = ( $msg =~ $site->regex ) ) { eval { %content = $site->get(@args) }; - $matching_url = $&; $content{playlist} = 0; last; } @@ -75,7 +70,6 @@ sub parse { and @args = ( $msg =~ $site->regex_playlist ) ) { eval { %content = $site->get_playlist(@args) }; - $matching_url = $&; $content{playlist} = 1; last; } @@ -86,16 +80,13 @@ sub parse { $log->warning($@); return; } - } else { - $matching_url = $content{matched_url}; - delete $content{matched_url}; } my $id; # if we get a new content, we must save it if (%content) { - ( $id, @matching_tags ) = + $id = insert_content( $kernel, $nick, $chan, dclone( \%content ), $msg, $playlist ); @@ -107,8 +98,6 @@ sub parse { } } } - - return ( $matching_url, @matching_tags ); } sub insert_content { @@ -200,7 +189,7 @@ sub insert_content { $dbh->commit; } - my @matching_tags = PlayBot::commands::parser::tag( $msg, $chan, $id ); + PlayBot::commands::parser::tag( $msg, $chan, $id ); my @tags; @@ -241,7 +230,7 @@ sub insert_content { privmsg => $chan => PlayBot::utils::print::print($content) ); } - return $content->{id}, @matching_tags; + return $content->{id}; } 1; -- GitLab