From: Steinar H. Gunderson Date: Fri, 18 Feb 2005 16:16:57 +0000 (+0000) Subject: Only insert a song if it doesn't already exist. X-Git-Url: https://git.sesse.net/?p=ccbs;a=commitdiff_plain;h=12f6f1727b74581d318163d769318a5794076935 Only insert a song if it doesn't already exist. --- diff --git a/parse/parse-ddrfreak-songlist.pl b/parse/parse-ddrfreak-songlist.pl index 7c02865..4fc1975 100644 --- a/parse/parse-ddrfreak-songlist.pl +++ b/parse/parse-ddrfreak-songlist.pl @@ -84,8 +84,9 @@ while (<>) { $songname =~ s/'/\\'/g; $artist =~ s/'/\\'/g; - printf "INSERT INTO songs (title,artist,minbpm,maxbpm) VALUES ('%s','%s',0,0);\n", - $songname, $artist; + # Insert the song only if it doesn't already exist + printf "INSERT INTO songs SELECT nextval('songs_song_seq') AS song, '%s' AS title, '%s' AS artist, 0 AS minbpm, 0 AS maxbpm WHERE '%s' NOT IN ( SELECT title FROM songs );\n", + $songname, $artist, $songname; for my $t (['single', 'beginner', $sb], ['single', 'standard', $ss],