From b3d94e20bd9310585756043fe74fc77ccefb3f29 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Thu, 11 Nov 2021 09:26:45 +0000 Subject: [PATCH] fix handling of database info --- bin/mpd-feeder | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/bin/mpd-feeder b/bin/mpd-feeder index f0ed182..3cc2206 100755 --- a/bin/mpd-feeder +++ b/bin/mpd-feeder @@ -236,26 +236,18 @@ SQL $mpd->send('listallinfo')->on_done( sub { try { - $db->begin; + my $rows = shift; + $db->begin_work; $db_generation++; - my ($song, $artist, $album); - - foreach my $row (@_) { - chomp($row); - - if ($row =~ s/^file:\s*//) { - $self->db_store_song( $song, $artist, $album ); - $song = $row; - $artist = $album = undef; - } - elsif ( $row =~ s/^Artist:\s*// ) { - $artist = $row; - } - elsif ( $row =~ s/^Album:\s*// ) { - $album = $row; - } + my $song_count; + + foreach my $entry (@$rows) { + next unless exists $entry->{file}; + $self->db_store_song( $entry->{file}, + $entry->{Artist}, $entry->{Album} ); + $song_count++; } $self->db_store_song($song, $artist, $album); -- 2.39.5