Closed hugolpz closed 6 months ago
I recommend this setting: https://kanasimi.github.io/wikiapi/Wikiapi.html#example__Login%20to%20wiki%20site%201 You may refer to this: https://github.com/kanasimi/wikibot/blob/master/wiki%20configuration.sample.js#L23
Try this:
require('./wiki loader.js');
wiki = new Wikiapi;
login_options = login_options_for_project.lingualibre;
await wiki.login(login_options);
Real-world sample: https://github.com/kanasimi/wikibot/blob/master/routine/20230418.Fix_redirected_wikilinks_of_templates.js#L73
Hello @kanasimi ,
I copied wiki configuration.js
and wiki loader.js
, recoded as you suggest, it runs, logs the following, but does nothing.
const Wikiapi= require('wikiapi');
// var logins = require('./logins.js');
const medialess = [
"Q145",
"Q146",
"Q147",/*
"Q148",
"Q149" /**/
]; // = require('./medialess.js')
require('./wiki loader.js');
(async () => {
// Connect
const targetWiki = new Wikiapi;
try{
// await targetWiki.login(USER, PASS, API);
await targetWiki.login({
language : 'en',
API_URL : 'https://lingualibre.org/api.php',
data_API_URL : 'https://lingualibre.org/api.php',
SPARQL_API_URL : 'https://lingualibre.org/bigdata/namespace/wdq/sparql',
user_name: 'Dragons Bot@Dragons_Bot',
password: 'mypassword',
//origin: '*',
});
}catch(e){console.error(e);}
for (var i=0;i<medialess.length;i++) {
try{
// update wikidata
let entity = await targetWiki.data(medialess[i]);
await entity.modify({ claims: [{ P24: 'Q88889' }] });
}catch(e){ console.error(e); }
}
})();
yug@yugpc2023:~/Documents/URFIST/Occitansiflé/Dragons_Bot$ node data-lingualibre.js
--------------------------------------------------------------------------------
wiki loader: 2023/12/20 0:44:3.527 Starting [data-lingualibre]
No task date assigned! 未指定任務日期。
get_API_parameters: 快取 lingualibre 的 API 模組資訊:模組路徑為 query+userinfo
get_API_parameters: 快取 lingualibre 的 API 模組資訊:模組路徑為 query+siteinfo
get_API_parameters: 快取 zhwiki 的 API 模組資訊:模組路徑為 query+userinfo
get_API_parameters: 快取 zhwiki 的 API 模組資訊:模組路徑為 query+siteinfo
Is this what you want? https://lingualibre.org/index.php?title=Q147&diff=1237913&oldid=881386
It worked ! @kanasimi I didn't see it yesterday night. Most of my tests edited over your edits. So there was no difference to push.
Congratulations! Looks like the problem is solved. You may set
set_language('fr');
It should be converted to French. (https://translatewiki.net/wiki/Translating:Colorless_echo_JavaScript_kit)
Hello @kanasimi , I hope you are going well.
Could you give a try to the following script after editing the logins. I tested the following wikibase editing on lingualibre.org api :
But I get the following error :
I'am able to query that api with my same logins and a wikipage script without issues. It fails when I edit the wikibase. So I suspect your code assumes wikibase editing is always toward wikidata api, where I'm not a bot and could be kicked out ?
If it works for you let me know.