From: Steinar H. Gunderson Date: Sun, 13 Feb 2005 16:42:42 +0000 (+0000) Subject: Add a script to parse the songlist from DDRNO's wiki. X-Git-Url: https://git.sesse.net/?p=ccbs;a=commitdiff_plain;h=5c5d48e56dcc7014a265bc61cd54378fad401c40 Add a script to parse the songlist from DDRNO's wiki. --- diff --git a/parse/parse-wiki-songlist.pl b/parse/parse-wiki-songlist.pl new file mode 100644 index 0000000..bfd4ccf --- /dev/null +++ b/parse/parse-wiki-songlist.pl @@ -0,0 +1,50 @@ +#! /usr/bin/perl +use strict; +use warnings; + +# Parses songlist from the DDRNO wiki + +while (<>) { + m/ + \| \s* \[\[ (.*?) \]\] \s* # song name + \|\| \s* \[\[ (.*?) \]\] \s* # artist + \|\| \s* (\d+(-\d+)?) \s* # bpm + \|\| \s* (\d+) \s* # single beginner + \|\| \s* (\d+) \s* # single standard + \|\| \s* (\d+) \s* # single difficult + \|\| \s* (\d+) \s* # single expert + \|\| \s* + \|\| \s* (\d+) \s* # double standard + \|\| \s* (\d+) \s* # double difficult + \|\| \s* (\d+) \s* # double expert + /x or next; + + my ($songname, $artist, $minbpm, $maxbpm, $sb, $ss, $sd, $se, $ds, $dd, $de) = + ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11); + + # fix some wikisyntax ickyness :-) + $artist =~ s/\]\]//g; + $artist =~ s/\[\[//g; + + # minimal SQL escaping + $songname =~ s/'/\'/g; + $artist =~ s/'/\'/g; + + $maxbpm = $minbpm if (!defined($maxbpm)); + ($maxbpm,$minbpm) = ($minbpm,$maxbpm) if ($maxbpm < $minbpm); + + printf "INSERT INTO songs (title,artist,minbpm,maxbpm) VALUES ('%s','%s',%u,%u);\n", + $songname, $artist, $minbpm, $maxbpm; + + for my $t (['single', 'beginner', $sb], + ['single', 'standard', $ss], + ['single', 'difficulty', $sd], + ['single', 'expert', $se], + ['double', 'standard', $ds], + ['double', 'difficulty', $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]; + } + +}