-
Notifications
You must be signed in to change notification settings - Fork 1
/
moveUlicaNs.js
44 lines (35 loc) · 1018 Bytes
/
moveUlicaNs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* Przenosi szkice artykułów o ulicach do namespace'a Ulica (id 2500)
*/
var bot = require('nodemw'),
client = new bot('config.js');
var SUMMARY = 'Przenoszenie szkiców artykułów o ulicach do oddzielnego namespace\'a',
STUB = '{{Szkic}}',
TEMPLATE = '{{Kandydat do przeniesienia|$1}}',
BATCH = 250;
client.logIn(function() {
client.getPagesInCategory('Ulice', function(pages) {
var stubsFound = 0,
idx = 0;
console.log("Articles: " + pages.length);
pages.forEach(function(page) {
if (page.ns !== 0) {
return;
}
if (++idx > BATCH) {
return;
}
client.getArticle(page.title, function(content) {
if (content.indexOf(STUB) === -1) {
return;
}
var newTitle = 'Ulica:' + page.title.replace(/^Ulica /, '');
stubsFound++;
console.log(" * #" + stubsFound + " stub found: " + page.title + " -> " + newTitle);
client.move(page.title, newTitle, SUMMARY, function() {
console.log(" # " + page.title + " moved");
});
});
});
});
});