my $sth = $db->prepare_cached("select $name from options");
$sth->execute;
my @result = $sth->fetchrow_array;
+ $sth->finish;
+ undef $sth;
return $result[0];
}
foreach my $entry (@$rows) {
next unless exists $entry->{file};
$self->db_store_song( $entry->{file},
- $entry->{Artist}, $entry->{Album} );
+ $entry->{AlbumArtist} // $entry->{Artist},
+ $entry->{Album} );
$song_count++;
}
$self->update_db;
my @result;
- my $sth = $db->prepare_cached(<<SQL);
+ my $sql = <<SQL;
SELECT s.path, s.artist, s.album
FROM songs s
JOIN artists ar ON ar.artist=s.artist
-JOIN albums al ON al.album=s.album
+JOIN albums al ON al.album=s.album AND al.artist=s.artist
WHERE (s.last_queued IS NULL OR s.last_queued < CURRENT_TIMESTAMP - (? || ' seconds')::interval)
AND (ar.last_queued IS NULL OR ar.last_queued < CURRENT_TIMESTAMP - (? || ' seconds')::interval)
AND (al.last_queued IS NULL OR al.last_queued < CURRENT_TIMESTAMP - (? || ' seconds')::interval)
ORDER BY random()
LIMIT ?
SQL
- $sth->execute(
- $opt->min_song_interval,
- $opt->min_artist_interval,
- $opt->min_album_interval,
- $num,
+ my @params = (
+ $opt->min_song_interval, $opt->min_artist_interval,
+ $opt->min_album_interval, $num,
);
+ my $sth = $db->prepare_cached($sql);
+ $sth->execute(@params);
while ( my @row = $sth->fetchrow_array ) {
push @result,
{ song => $row[0], artist => $row[1], album => $row[2] };
}
+ undef $sth;
return @result;
}
}
}
+$feeder->connect_db;
+
for ( ;; ) {
$feeder->queue_songs( undef, sub { $feeder->run } );