Closed hugolpz closed 10 months ago
@hugolpz I think I might have to try uploading files. If I finish the test, can you delete the test files?
Important : for me, the same error pops up for Wikimédia Commons (bot or user's account), and Lingualibre.org After a year away I'm rusty, I may do things wrong somewhere but I don't know. So after fighting unsuccessfully on a single error I report it here. My apologizes for the juniorship and thank you too.
I don't get this error in Commons. Maybe it's a version problem? I'll update it and see...
If the problem persists, please reopen this issue.
Hello @Kanasimi,
I super-simplified my code in order to lead a minimalist test, it still stales for upload()
to Commons.
$ node --version
v20.10.0
$ npm list
dragons-bot@0.0.1 /home/yug/Documents/communal/WikiVoc/Dragons_Bot
├── cejs@4.5.7
├── node-fetch@2.7.0
├── npm-check-updates@16.14.12
└── wikiapi@1.19.5
Dragons_Bot is able to login and edit Commons without issue, see : https://commons.wikimedia.org/wiki/Special:Contributions/Dragons_Bot
But the following wiki.upload()
code stales despite all my simplifications :
// PURPOSE: Script to upload targets
// Run: $node wiki-upload-many.js
const Wikiapi= require('wikiapi');
const logins = require('./logins.js');
(async () => {
// Connect
const wiki = new Wikiapi;
await wiki.login({
language : 'en',
API_URL : logins.commons.api,
data_API_URL : logins.commons.api,
//SPARQL_API_URL : '...'
user_name: logins.commons.user,
password: logins.commons.pass,
//origin: '*', // if commented then connect
});
console.log(`Username Dragons Bot is connected !`);
/* *************************************************************** */
/* CORE ACTION(S) HERE : HACK ME ! ******************************* */
// Set upload parameters, maily for licensing reasons.
// Note: parameter `text`, filled with the right wikicode `{{description|}}`, can replace most parameters.
let options = {
author: `[[User:Dragons Bot|]]`,
date: new Date().toISOString().split('T')[0],
description: `Chinese mandarin audio`,
other_versions: '',
other_fields: '',
permission: `{{own}}`,
categories: [`[[Category:Dragons Bot test: upload]]` ],
bot: 1,
// tags:"tag1|tag2",
};
for(i=0;i<1;i++){
try{
wiki.upload({
file_path: "./data/Dragons_Bot_test.jpg", // <======================================== CREATE THIS FILE TO TEST
//source_url: 'https://github.com/kanasimi/wikiapi',
filename: "Dragons_Bot_Test.jpg",
comment: `Upload Shtooka recorder file {TITLE} as Lingua Libre item.`,
ignorewarnings: 1,
bot: 1,
license: ['{{cc-by-sa-3.0}}' ],
//text: 'Wikibot test, wait few hours before {{tl|speedy}}.',
...options,
});
/**/
}catch(e){ console.error('Fails upload: '+ e); }
}
/* END CORE ****************************************************** */
/* *************************************************************** */
})();
It runs for 30secs with 4 logs printed then stales . No error.
$ node ./wiki-upload-test.js
get_API_parameters: Cache information about the API modules of commonswiki: module path=query+userinfo
get_API_parameters: Cache information about the API modules of commonswiki: module path=query+siteinfo
Username Dragons Bot is connected !
get_API_parameters: Cache information about the API modules of commonswiki: module path=upload
You may need an image or file to upload (this one below may already be on commons )
Any test or code change I may do to help this investigation ?
Hello @kanasimi.
Same, stalling, no error, no upload with the JS code above. Upload to Commons does work for you ?
package.json
:
"dependencies": {
"cejs": "github:kanasimi/cejs",
// "npm-check-updates": "latest",
"wikiapi": "github:kanasimi/wikiapi"
}
npm list
:
$ npm list --depth=1
dragons-bot@0.0.1 /home/yug/Documents/communal/WikiVoc/Dragons_Bot
├── cejs@4.5.7 (git+ssh://git@github.com/kanasimi/cejs.git#0f3d34255e18fbf8df9b9f72b50e073759060dec)
└─┬ wikiapi@1.19.5 (git+ssh://git@github.com/kanasimi/wikiapi.git#02ec0a3a9121a8bbb972b69f81f18b882a0ed37c)
└── cejs@4.5.7
And my local cejs is the latest cejs 👍🏼
Sorry I forgot to update npm. please use version 4.5.8.
Hello Kanasimi,
I continue to fight but I still hit some walls.
I have a upload files call such as :
And I get the error :
Any ideas ?