summaryrefslogtreecommitdiff
path: root/wikiscraper.pl
blob: a482bcb7d4d98011ce4f8e2e3bd2276e11602dbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/perl

# MediaWiki -> RCS scraper

use warnings;
use strict;

require MediaWiki::DumpFile::Pages;

my $dumpfile = MediaWiki::DumpFile::Pages->new(shift @ARGV);
# 83Plus:Ports:57

while (defined (my $page = $dumpfile->next))
{
    my @revs = $page->revision;

    foreach (@revs) {
	open (FILE, ">", $page->title);
	print FILE $_->text;
	close FILE;

	my $user = $_->contributor->id;
	if (!defined $user) {
	    $user = $_->contributor->ip;
	    $user =~ s/\./_/g;
	    $user = "ip_" . $user;
	} else {
	    $user = "id_" . $user;
	}
	my @command = ("ci",
		       "-t-" . $page->title,
		       "-d" . $_->timestamp,
		       ($_->comment ne "" ? "-m" . $_->comment : "-mNo message"),
		       "-r" . $_->id,
		       "-w" . $user,
		       "-l",
		       $page->title,
	    );

	print join " ", @command, "\n";
	system(@command);
    }
}