6 # Parses tournament results from the DDR Europe result list
9 my ($name, $round, $group, $player, @rsongs);
10 die "Missing season (give on command line)." if (!defined($season));
12 # commented out -- see player below
16 if (/<h2> \s* (.*?) \s* <\/h2>/x) {
20 if (/<br>Country: \s* (.*?) \s*
21 <br>Location: \s* (.*?) \s*
22 <br>Date: \s* (.*?) \s*
23 <br>Mix: \s* (.*?) \s*
24 <br>ScoringSystem: \s* (.*?) \s* <br>
26 my ($country, $location, $date, $mix, $system) = ($1, $2, $3, $4, $5);
27 $mix =~ s/Euromix/EuroMix/;
29 print "INSERT INTO tournaments \n";
30 print " (season, name, country, location, \"date\", machine, scoringsystem) VALUES (\n";
31 print " (SELECT season FROM seasons WHERE name='$season'),\n";
33 print " (SELECT country FROM countries WHERE name='$country'),\n";
34 print " '$location',\n";
35 printf " '%s',\n", Date::Manip::UnixDate($date, '%Y-%m-%d');
36 print " (SELECT machine FROM machines WHERE name='$mix'),\n";
37 print " (SELECT scoringsystem FROM scoringsystems WHERE name='$system')\n";
42 if (/<h3 \s* class=dthr> Round \s* (\d+) \s* <\/h3>/x) {
45 print "INSERT INTO rounds (tournament, round, randomsongs, chosensongs) \n";
47 print " (SELECT tournament FROM tournaments WHERE name='$name'),\n";
49 print " 0, 0);\n"; # Don't worry, we'll fix it later :-P
52 # New group, and the random songs for it
53 if (/<th \s* class=dthp> ( Players | Group \s* (\d+) )<\/th>/x) {
54 # bit of an evil hack here
56 $group = 0 if ($1 eq 'Players');
58 print "INSERT INTO groups (tournament, round, parallel) VALUES (\n";
59 print " (SELECT tournament FROM tournaments WHERE name='$name'),\n";
60 print " $round, $group);\n";
62 # Find the random songs, if any
65 while (s/<th \s* class=dthpsong> .*? "color:white"> (.*?) <\/a><\/th>//x) {
66 my $song = song_map($1);
71 print "INSERT INTO roundrandomsongs (tournament, round, parallel, song) VALUES (\n";
72 print " (SELECT tournament FROM tournaments WHERE name='$name'),\n";
73 print " $round, $group,\n";
74 print " (SELECT song FROM songs WHERE lower(title)=lower('$song'))\n";
78 # Correct the random songs in the table
79 printf "UPDATE rounds SET randomsongs=%u WHERE \n", scalar @rsongs;
80 print " tournament=(SELECT tournament FROM tournaments WHERE name='$name') AND \n";
81 print " round=$round;\n";
84 # Header for chosen song (evil)
85 if (/<th \s* class=dthp \s* colspan=2> <\/th>/x) {
86 printf "UPDATE rounds SET chosensongs=1 WHERE \n";
87 print " tournament=(SELECT tournament FROM tournaments WHERE name='$name') AND \n";
88 print " round=$round;\n";
91 # Player's results (header)
92 if (/^ <tr><td \s* class=dtd> .*? class="link"> (.*?) <\/a> $/x) {
94 printf "INSERT INTO players (nick) VALUES ('%s');\n", $player;
97 # Player's results (score)
98 if (/<td \s* class=dtdm>/x) {
102 while (s/<td \s* class=dtdm> (\d+) <\/td>//x) {
103 printf "INSERT INTO scores (tournament, round, parallel, player, song, chosen, score) VALUES (\n";
104 print " (SELECT tournament FROM tournaments WHERE name='$name'),\n";
105 print " $round, $group,\n";
106 print " (SELECT player FROM players WHERE nick='$player'),\n";
107 print " (SELECT song FROM songs WHERE lower(title)=lower('$rsongs[$i]')),\n";
114 while (s/<td \s* class=dtdsong> .*? class="link"> (.*?) <\/a> .*? <td class=dtdscore> (\d+) <\/td>//x) {
115 my $song = song_map($1);
118 printf "INSERT INTO scores (tournament, round, parallel, player, song, chosen, score) VALUES (\n";
119 print " (SELECT tournament FROM tournaments WHERE name='$name'),\n";
120 print " $round, $group,\n";
121 print " (SELECT player FROM players WHERE nick='$player'),\n";
122 print " (SELECT song FROM songs WHERE lower(title)=lower('$song')),\n";
131 # different names for songs
135 $song =~ s/Paranoia -Rebirth-/PARANOiA Rebirth/;
136 $song =~ s/The Center of the heart/The Centre of the Heart (Stonebridge Club Mix)/;
137 $song =~ s/Can't stop falling in love/Can't Stop Fallin' in Love/;
138 $song =~ s/B4U -B4 ZA Beat Mix-/B4U (B4 Za Beat Mix)/;
139 $song =~ s/Jam Jam Reggae/Jam Jam Reggae (AM Swing Mix)/;
140 $song =~ s/Trip Machine -Climax-/Trip Machine Climax/;
141 $song =~ s/Dont try to stop it/Don't Try to Stop It/;
142 $song =~ s/Healing Vision -AM-/Healing Vision (Angelic Mix)/;
143 $song =~ s/5,6,7,8/5, 6, 7, 8/;
144 $song =~ s/Keep On Movin/Keep On Movin'/;
145 $song =~ s/So Deep/So Deep (Perfect Sphere Mix)/;
146 $song =~ s/Aarons Party/Aaron's Party (Come Get It)/;