X-Git-Url: https://git.sesse.net/?p=ccbs;a=blobdiff_plain;f=parse%2Fparse-ddrfreak-songlist.pl;h=d4f3e5c937d5e0f742de21a6df97efb6f46addc5;hp=4fc1975088497821c1dffdf6bb7bc9662362964f;hb=3200c9792d41a6a7a5edea7747fd613fae609798;hpb=12f6f1727b74581d318163d769318a5794076935 diff --git a/parse/parse-ddrfreak-songlist.pl b/parse/parse-ddrfreak-songlist.pl index 4fc1975..d4f3e5c 100644 --- a/parse/parse-ddrfreak-songlist.pl +++ b/parse/parse-ddrfreak-songlist.pl @@ -80,13 +80,27 @@ while (<>) { or die "Parse error, line 11"; my $dc = $1; + # Blarg, hack + if ($songname eq 'FANTASY') { + $songname = "$songname ($artist)"; + } + + # Some HTML -> UTF-8 stuff + $songname =~ s/♥/\xe2\x9d\xa4/g; + $songname =~ s/∀/\xe2\x88\x80/g; + $songname =~ s/★/\xe2\x98\x85/g; + $songname =~ s/é/\xc3\xa9/g; + $songname =~ s/2<\/sup>/\xc2\xb2/g; + # minimal SQL escaping $songname =~ s/'/\\'/g; $artist =~ s/'/\\'/g; # 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", + printf "INSERT INTO songs SELECT nextval('songs_song_seq') AS song, '%s' AS title, '%s' AS artist, 0 AS minbpm, 0 AS maxbpm WHERE LOWER('%s') NOT IN ( SELECT LOWER(title) FROM songs );\n", $songname, $artist, $songname; + printf "INSERT INTO machinesongs SELECT ( SELECT song FROM songs WHERE LOWER(title)=LOWER('%s') ), ( SELECT machine FROM machines WHERE machinename='%s' );\n", + $songname, $machine; for my $t (['single', 'beginner', $sb], ['single', 'standard', $ss], @@ -98,7 +112,7 @@ while (<>) { ['double', 'expert', $de], ['double', 'challenge', $dc]) { next if (!defined($t->[2]) || $t->[2] eq ''); - printf "INSERT INTO songratings (song,machine,playmode,difficulty,feetrating) VALUES ((SELECT song FROM songs WHERE title='%s'),(SELECT machine FROM machines WHERE machinename='%s'),'%s','%s',%u);\n", + printf "INSERT INTO songratings (song,machine,playmode,difficulty,feetrating) VALUES ((SELECT song FROM songs WHERE LOWER(title)=LOWER('%s')),(SELECT machine FROM machines WHERE machinename='%s'),'%s','%s',%u);\n", $songname, $machine, $t->[0], $t->[1], $t->[2]; } }