LibreCat / Catmandu-MediaWiki

Catmandu modules for MediaWiki
Other
0 stars 0 forks source link

Question: Is it possible to query list of category members? #1

Open michal-josef-spacek opened 3 weeks ago

michal-josef-spacek commented 3 weeks ago

Hi, I am trying to fetch the list of category members and I am not sure that module is working.

This command

catmandu convert MediaWiki --url https://cs.wikipedia.org/w/api.php --generate categorymembers to CSV

is fine, but I am not able to set --args. Is it possible to set --args with the command line?

nicolasfranck commented 3 weeks ago

Apparently not, but it does work programmatically:

#!/usr/bin/env perl

use Catmandu;
use Catmandu::Importer::MediaWiki;
use Catmandu::Exporter::YAML;

my $exporter = Catmandu::Exporter::YAML->new;
$exporter->add_many(Catmandu::Importer::MediaWiki->new(
    url => "https://cs.wikipedia.org/w/api.php",
    generate => "categorymembers",
    args => {
        gaplimit => 2,
        gcmpageid => 1,
    }
));
$exporter->commit;

For debugging, you can always set export LWP_TRACE=1 to see what requests are sent by the underlying web client

I know that the cli command convert uses Getopt::Long somewhere down the line, and that that module needs a certain syntax to specify hashes on the command line (e.g. var=s%). Unfortunately, the importers themselves have no control over how that convert command turns their options into cli options.

@nics any idea?

michal-josef-spacek commented 3 weeks ago

@nicolasfranck Thank you for the answer.

I'm a little disappointed that there is no documentation in Catmandu::MediaWiki page.

I need to think about both things.

nicolasfranck commented 2 weeks ago

This module has not been updated in 8 years, never had any proven use, and will not be updated anymore (and I should probably archive this git repo). Isn't it more prudent to use the module MediaWiki::API directly?

michal-josef-spacek commented 2 weeks ago

@nicolasfranck I think, that it's nice to use some MediaWiki-related things in the Catmandu ecosystem, mainly in catmandu command. The question is how? :-)

My original question to myself was "How to fetch list of articles from MediaWiki category in Catmandu?". And I don't found better resolution than this module.

So I am ok with improving this module. The ways are: 1) Process structure from arguments to set things. There is something like --var, but I don't think that for this intention. I need to read doc again. 2) Add some aliases commands to use e.g. Fetch category members. 3) ...