On Wed, May 30, 2012 at 12:48 AM, Jools Wills buzz@exotica.org.uk wrote:
On 29/05/12 23:41, nguyenkim thuat wrote:
I just know the version of my mediawiki. it's 1.15.5-1
ok so you cant use the "edit" function then - thats for 1.16 and greater. 1.15 is very old.
Check which version of the cpan mediawiki::api module also - you should get the latest (0.39)
Best Regards
Jools
My mediawiki version now is: MediaWiki https://www.mediawiki.org/ 1.19.0 PHP http://www.php.net/ 5.3.3-1ubuntu9.10 (apache2handler) SQLite http://sqlite.org/ 3.7.2 with full-text search support I use the api->edit as your suggestions but it generated an error. The code is: * $mediawiki->edit( { action => 'upload', filename => $name, comment => 'upload a file', file => [$name], ignorewarnings => 1, bot => 1 } ) || die $mediawiki->{error}->{code} . ': ' . $mediawiki->{error}->{details}; * *Logged in with user "WikiAdmin". 22 bytes read 5: Unable to get an edit token for action 'upload'. at upload.pl line 35.*
So i do need to get a token before uploading a file with this newest version of mediawiki?
On 06/06/12 10:15, nguyenkim thuat wrote:
My mediawiki version now is: MediaWiki https://www.mediawiki.org/ 1.19.0 PHP http://www.php.net/ 5.3.3-1ubuntu9.10 (apache2handler) SQLite http://sqlite.org/ 3.7.2 with full-text search support
you didnt list which version of the MediaWiki::API module you are using.
Best Regards
Jools
On Thu, Jun 7, 2012 at 1:21 PM, Jools Wills buzz@exotica.org.uk wrote:
On 06/06/12 10:15, nguyenkim thuat wrote:
My mediawiki version now is: MediaWiki https://www.mediawiki.org/ 1.19.0 PHP http://www.php.net/ 5.3.3-1ubuntu9.10 (apache2handler) SQLite http://sqlite.org/ 3.7.2 with full-text search support
you didnt list which version of the MediaWiki::API module you are using.
Best Regards
Jools
I'm using the version 0.33 of Mediawiki::API. So i need to upgrade it?
Thuat.
Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.**org Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/**mailman/listinfo/mediawiki-apihttps://lists.wikimedia.org/mailman/listinfo/mediawiki-api
I'm using the version 0.33 of Mediawiki::API. So i need to upgrade it?
yes. 0.33 was released two years ago, before the mediawiki API had support for file uploads (1.16 which had this support was released a month or two after). 0.39 is on cpan.
http://search.cpan.org/~exobuzz/MediaWiki-API-0.39/
Best Regards
Jools
Yeah, I tried to install this version, after installing all of the packages prerequise , and tape make install. it generate this line:
*Appending installation info to /usr/local/lib/perl/5.10.1/perllocal.pod*
Nothing change, my version is still 0.33. Do i have to move the file API.pm in *lib/Mediawiki* to the folder /usr/shared/perl5/Mediawiki/API.pm?
On Thu, Jun 7, 2012 at 5:13 PM, Jools Wills buzz@exotica.org.uk wrote:
I'm using the version 0.33 of Mediawiki::API. So i need to upgrade it?
yes. 0.33 was released two years ago, before the mediawiki API had support for file uploads (1.16 which had this support was released a month or two after). 0.39 is on cpan.
http://search.cpan.org/~**exobuzz/MediaWiki-API-0.39/http://search.cpan.org/%7Eexobuzz/MediaWiki-API-0.39/
Best Regards
Jools
______________________________**_________________ Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.**org Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/**mailman/listinfo/mediawiki-apihttps://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Sorry, i just have another question.
Is it possible to download old versions of a file (image, pdf ..) with the function MediaWiki::API->download( $params_hashref )http://search.cpan.org/%7Eexobuzz/MediaWiki-API-0.39/lib/MediaWiki/API.pm#MediaWiki::API-%3Edownload%28_$params_hashref_%29? When I tried to call this function for example with filename * '20120606205541!Test.txt'* which is located in directory images/archive/ I got empty result. According to the documentation of the download function, it means the file doesn't exist on the MediaWiki. *"If the file does not exist (on the wiki) an empty string is returned. If the file is unable to be downloaded undef is returned.*"
Thanks.
On Thu, Jun 7, 2012 at 5:48 PM, nguyenkim thuat < kim-thuat.nguyen@ensimag.imag.fr> wrote:
Yeah, I tried to install this version, after installing all of the packages prerequise , and tape make install. it generate this line:
*Appending installation info to /usr/local/lib/perl/5.10.1/perllocal.pod*
Nothing change, my version is still 0.33. Do i have to move the file API.pm in *lib/Mediawiki* to the folder /usr/shared/perl5/Mediawiki/API.pm?
On Thu, Jun 7, 2012 at 5:13 PM, Jools Wills buzz@exotica.org.uk wrote:
I'm using the version 0.33 of Mediawiki::API. So i need to upgrade it?
yes. 0.33 was released two years ago, before the mediawiki API had support for file uploads (1.16 which had this support was released a month or two after). 0.39 is on cpan.
http://search.cpan.org/~**exobuzz/MediaWiki-API-0.39/http://search.cpan.org/%7Eexobuzz/MediaWiki-API-0.39/
Best Regards
Jools
______________________________**_________________ Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.**org Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/**mailman/listinfo/mediawiki-apihttps://lists.wikimedia.org/mailman/listinfo/mediawiki-api
On 07/06/12 17:07, nguyenkim thuat wrote:
When I tried to call this function for example with filename *'20120606205541!Test.txt'* which is located in directory images/archive/ I got empty result. According to the documentation of the download function, it means the file doesn't exist on the MediaWiki. */"If the file does not exist (on the wiki) an empty string is returned. If the file is unable to be downloaded undef is returned./*"
the "name" is the name in the wiki - ie File:Something.jpg - not the on disk name. the download call was a shortcut to get the last version only.
Read the API documentation here - http://www.mediawiki.org/wiki/APIin this case you can use imageinfo.
http://en.wikipedia.org/w/api.php?action=query&titles=Image:Albert%20Ein...
Best Regards
Jools
On Fri, Jun 8, 2012 at 8:27 PM, Jools Wills buzz@exotica.org.uk wrote:
On 07/06/12 17:07, nguyenkim thuat wrote:
When I tried to call this function for example with filename
*'20120606205541!Test.txt'* which is located in directory
images/archive/ I got empty result. According to the documentation of the download function, it means the file doesn't exist on the MediaWiki. */"If the file does not exist (on the wiki) an empty string is returned. If the file is unable to be downloaded undef is returned./*"
the "name" is the name in the wiki - ie File:Something.jpg - not the on disk name. the download call was a shortcut to get the last version only.
Read the API documentation here - http://www.mediawiki.org/wiki/**APIinhttp://www.mediawiki.org/wiki/APIinthis case you can use imageinfo.
http://en.wikipedia.org/w/api.**php?action=query&titles=Image:** Albert%20Einstein%20Head.jpg&**prop=imageinfo&iilimit=4&**iiprop=urlhttp://en.wikipedia.org/w/api.php?action=query&titles=Image:Albert%20Einstein%20Head.jpg&prop=imageinfo&iilimit=4&iiprop=url
Thanks you so much, now i have all the urls of a file from my wiki using
this method. sub getFileArchive { mw_connect_maybe(); my $filename = shift; my $query = { action => 'query', prop => 'imageinfo', titles => $filename, iilimit => 4, iiprop => 'url', }; my $result = $mediawiki->api($query);
my ($pageID,$page) = each (%{$result->{query}->{pages}}); if (defined($page->{imageinfo})) { while (my $urlFile = pop(@{$page->{imageinfo}})) { my $host = $urlFile->{url}; print "$host\n"; } } }
*Logged in with user "WikiAdmin". http://localhost/wiki/images/archive/0/07/20120609160413%21Toilamduoc.png http://localhost/wiki/images/0/07/Toilamduoc.png * But now how i can download these files, the method *dowload* seem to be not able to download the files from the archive? Thanks.
______________________________**_________________ Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.**org Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/**mailman/listinfo/mediawiki-apihttps://lists.wikimedia.org/mailman/listinfo/mediawiki-api
/Logged in with user "WikiAdmin". http://localhost/wiki/images/archive/0/07/20120609160413%21Toilamduoc.png http://localhost/wiki/images/0/07/Toilamduoc.png / But now how i can download these files, the method /dowload/ seem to be not able to download the files from the archive?
you can use LWP::UserAgent (as my module does) or WWW:Mechanize which is even simpler (http://search.cpan.org/dist/WWW-Mechanize/) or WWW:Curl
The Download function is for "mediawiki named" files - not the on disk filename - it just gets the last file revision.
my download function gets the url for the last image revision and then
$response = LWP::UserAgent->get($url); checks the $response->code
and if ok returns the $response->decoded_content;
so you could do the same with the urls. you can even reuse the mediawiki::Api objects lwp useragent if you like and do ($mw = MediaWiki::API object - configured and ready)
$response = $mw->{ua}->get($url); and if ok, open a new file for writing and write the contents out.
some of the modules mentioned earlier (and perhaps even UserAgent) are sure to have oneliners for this if you prefer. for large files they might be smarter too.
Best Regards
Jools
On Sun, Jun 10, 2012 at 3:02 AM, Jools Wills buzz@exotica.org.uk wrote:
/Logged in with user "WikiAdmin".
http://localhost/wiki/images/**archive/0/07/20120609160413%** 21Toilamduoc.pnghttp://localhost/wiki/images/archive/0/07/20120609160413%21Toilamduoc.png http://localhost/wiki/images/**0/07/Toilamduoc.pnghttp://localhost/wiki/images/0/07/Toilamduoc.png / But now how i can download these files, the method /dowload/ seem to be
not able to download the files from the archive?
you can use LWP::UserAgent (as my module does) or WWW:Mechanize which is even simpler (http://search.cpan.org/dist/**WWW-Mechanize/http://search.cpan.org/dist/WWW-Mechanize/) or WWW:Curl
The Download function is for "mediawiki named" files - not the on disk filename - it just gets the last file revision.
my download function gets the url for the last image revision and then
$response = LWP::UserAgent->get($url); checks the $response->code
and if ok returns the $response->decoded_content;
so you could do the same with the urls. you can even reuse the mediawiki::Api objects lwp useragent if you like and do ($mw = MediaWiki::API object - configured and ready)
$response = $mw->{ua}->get($url); and if ok, open a new file for writing and write the contents out.
some of the modules mentioned earlier (and perhaps even UserAgent) are sure to have oneliners for this if you prefer. for large files they might be smarter too.
Best Regards
Jools
Thank you so much for your help, now i'm able to download all the files from the archives. i used the LWP::UserAgent as your suggestion * my $ua = LWP::UserAgent->new( timeout => 25 ); my $response = $ua->get($url); if ($response->code) { $response = $response->decoded_content; } * Thuat.
______________________________**_________________ Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.**org Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/**mailman/listinfo/mediawiki-apihttps://lists.wikimedia.org/mailman/listinfo/mediawiki-api
On 07/06/12 16:48, nguyenkim thuat wrote:
Yeah, I tried to install this version, after installing all of the packages prerequise , and tape make install. it generate this line:
*Appending installation info to /usr/local/lib/perl/5.10.1/perllocal.pod*
Nothing change, my version is still 0.33. Do i have to move the file API.pm in /lib/Mediawiki/ to the folder /usr/shared/perl5/Mediawiki/API.pm?
it should pick up the version installed in /usr/local.
If you have installed the earlier version from a package manager or so, I suggest removing that also.
Best Regards
Jools
mediawiki-api@lists.wikimedia.org