From: Damyan Ivanov Date: Thu, 11 Nov 2021 09:26:45 +0000 (+0000) Subject: fix handling of database info X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=b3d94e20bd9310585756043fe74fc77ccefb3f29;p=mpd-feeder.git fix handling of database info --- 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);