]> git.sesse.net Git - ccbs/commitdiff
Add a script to parse the CCBS player list and set countries and clubs correctly.
authorSteinar H. Gunderson <Steinar H. Gunderson sesse@debian.org>
Thu, 9 Feb 2012 22:20:15 +0000 (23:20 +0100)
committerSteinar H. Gunderson <Steinar H. Gunderson sesse@debian.org>
Thu, 9 Feb 2012 22:20:15 +0000 (23:20 +0100)
parse/parse-ccbs-playerlist.pl [new file with mode: 0644]

diff --git a/parse/parse-ccbs-playerlist.pl b/parse/parse-ccbs-playerlist.pl
new file mode 100644 (file)
index 0000000..d6a141f
--- /dev/null
@@ -0,0 +1,28 @@
+#! /usr/bin/perl
+use strict;
+use warnings;
+use Date::Manip;
+
+# Parses players from our own HTML, to get the clubs and nationalities right.
+
+print "begin;\n";
+
+while (<>) {
+       if (/^ \s* <td><a \s* href=".*\/player\.pl\?id=\d+"> (.*?) <\/a><\/td> \s* $/x) {
+               my $nick = $1;
+       
+               chomp ($_ = <>);
+               /<td> (.*?) <\/td>/x or die;
+               my $country = $1;
+       
+               chomp ($_ = <>);
+               /<td> (.*?) <\/td>/x or die;
+               my $club = $1;
+
+               print "UPDATE players SET\n";
+               print "  country=(SELECT country FROM countries WHERE countryname='$country'),\n";
+               print "  club=(SELECT club FROM clubs WHERE clubname='$club') WHERE nick='$nick';\n";
+       }
+}
+
+printf "commit;\n";