use strict;
use warnings;
+my $machine = shift;
+die "Missing machine (first argument on the command line)" if (!defined($machine));
+
# Parses songlist from the DDRNO wiki
+print "begin;\n";
+
while (<>) {
m/
\| \s* \[\[ (.*?) \]\] \s* # song name
\|\| \s* \[\[ (.*?) \]\] \s* # artist
- \|\| \s* (\d+(-\d+)?) \s* # bpm
+ \|\| \s* (\d+(?:-(\d+))?) \s* # bpm
\|\| \s* (\d+) \s* # single beginner
\|\| \s* (\d+) \s* # single standard
\|\| \s* (\d+) \s* # single difficult
$artist =~ s/\[\[//g;
# minimal SQL escaping
- $songname =~ s/'/\'/g;
- $artist =~ s/'/\'/g;
+ $songname =~ s/'/\\'/g;
+ $artist =~ s/'/\\'/g;
$maxbpm = $minbpm if (!defined($maxbpm));
($maxbpm,$minbpm) = ($minbpm,$maxbpm) if ($maxbpm < $minbpm);
for my $t (['single', 'beginner', $sb],
['single', 'standard', $ss],
- ['single', 'difficulty', $sd],
+ ['single', 'difficult', $sd],
['single', 'expert', $se],
['double', 'standard', $ds],
- ['double', 'difficulty', $dd],
+ ['double', 'difficult', $dd],
['double', 'expert', $de]) {
- printf "INSERT INTO songratings (song,playmode,difficulty,feetrating) VALUES ((SELECT song FROM songs WHERE title='%s'),'%s','%s',%u);\n",
- $songname, $t->[0], $t->[1], $t->[2];
+ 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",
+ $songname, $machine, $t->[0], $t->[1], $t->[2];
}
-
}
+
+printf "commit;\n";