]> git.sesse.net Git - ccbs/blobdiff - parse/parse-ddrfreak-songlist.pl
Only insert a song if it doesn't already exist.
[ccbs] / parse / parse-ddrfreak-songlist.pl
index 7c02865f3dd21f6552d7a1db001ccd30aee892e5..4fc1975088497821c1dffdf6bb7bc9662362964f 100644 (file)
@@ -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],