Last active
July 30, 2019 22:20
-
-
Save Ladsgroup/20bc5503875da318a1b4960e458d2505 to your computer and use it in GitHub Desktop.
Commons cleaner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# License: CC-0 | |
var api = new mw.Api(); | |
function block() { | |
var params = { | |
action:'query', | |
prop: 'imageinfo', | |
generator: 'search', | |
gsrsearch: 'incaption:"no caption, no cc-zero"', | |
gsrnamespace: 6, | |
gsrlimit: 50 | |
} | |
api.get( params).done(function(data) { | |
var cases = []; | |
for ( x in data.query.pages ) { | |
cases.push(data.query.pages[x].title); | |
} | |
var params = { | |
action:'wbgetentities', | |
sites: 'commonswiki', | |
titles: cases.join('|')}; | |
api.get( params).done(function(data) { | |
for ( x in data['entities'] ) { | |
if ( data['entities'][x].labels && data['entities'][x].labels.en && data['entities'][x].labels.en.value == 'no caption, no cc-zero') { | |
var params = {action:'wbsetlabel', | |
id:x, | |
value:'', | |
language:'en'}; | |
api.postWithEditToken(params).then(console.log, console.error); | |
} | |
}; | |
}); | |
console.log('one batch done'); | |
}); | |
} | |
block(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment