sub get_mw_tracked_namespaces {
my $pages = shift;
- foreach my $local_namespace (@tracked_namespaces) {
+ foreach my $local_namespace (sort @tracked_namespaces) {
+ my $namespace_id;
+ if ($local_namespace eq "(Main)") {
+ $namespace_id = 0;
+ } else {
+ $namespace_id = get_mw_namespace_id($local_namespace);
+ }
+ # virtual namespaces don't support allpages
+ next if !defined($namespace_id) || $namespace_id < 0;
my $mw_pages = $mediawiki->list( {
action => 'query',
list => 'allpages',
- apnamespace => get_mw_namespace_id($local_namespace),
+ apnamespace => $namespace_id,
aplimit => 'max' } )
|| die $mediawiki->{error}->{code} . ': '
. $mediawiki->{error}->{details} . "\n";
+ print {*STDERR} "$#{$mw_pages} found in namespace $local_namespace ($namespace_id)\n";
foreach my $page (@{$mw_pages}) {
$pages->{$page->{title}} = $page;
}
my $id;
if (!defined $ns) {
- print {*STDERR} "No such namespace ${name} on MediaWiki.\n";
+ my @namespaces = map { s/ /_/g; $_; } sort keys %namespace_id;
+ print {*STDERR} "No such namespace ${name} on MediaWiki, known namespaces: @namespaces\n";
$ns = {is_namespace => 0};
$namespace_id{$name} = $ns;
}