6 die "Missing machine (first argument on the command line)" if (!defined($machine));
8 # Parses songlist from the DDRNO wiki
14 \| \s* \[\[ (.*?) \]\] \s* # song name
15 \|\| \s* \[\[ (.*?) \]\] \s* # artist
16 \|\| \s* (\d+(?:-(\d+))?) \s* # bpm
17 \|\| \s* (\d+) \s* # single beginner
18 \|\| \s* (\d+) \s* # single standard
19 \|\| \s* (\d+) \s* # single difficult
20 \|\| \s* (\d+) \s* # single expert
22 \|\| \s* (\d+) \s* # double standard
23 \|\| \s* (\d+) \s* # double difficult
24 \|\| \s* (\d+) \s* # double expert
27 my ($songname, $artist, $minbpm, $maxbpm, $sb, $ss, $sd, $se, $ds, $dd, $de) =
28 ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11);
30 # fix some wikisyntax ickyness :-)
34 # minimal SQL escaping
35 $songname =~ s/'/\\'/g;
38 $maxbpm = $minbpm if (!defined($maxbpm));
39 ($maxbpm,$minbpm) = ($minbpm,$maxbpm) if ($maxbpm < $minbpm);
41 printf "INSERT INTO songs (title,artist,minbpm,maxbpm) VALUES ('%s','%s',%u,%u);\n",
42 $songname, $artist, $minbpm, $maxbpm;
44 for my $t (['single', 'beginner', $sb],
45 ['single', 'standard', $ss],
46 ['single', 'difficult', $sd],
47 ['single', 'expert', $se],
48 ['double', 'standard', $ds],
49 ['double', 'difficult', $dd],
50 ['double', 'expert', $de]) {
51 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",
52 $songname, $machine, $t->[0], $t->[1], $t->[2];