pandora_scripts/add_number.py
2018-08-05 19:00:17 +01:00

24 lines
465 B
Python
Executable file

#!/usr/bin/python3
import sys
import ox.api
site = sys.argv[1]
prefix = 'cnv'
api = ox.api.signin(site)
n = 1
for item in api.find({
'query': {
'conditions': [{'key': 'title', 'value': prefix, 'operator': '^'}]
},
'keys': ['id', 'title'],
'sort': [{'key': 'created', 'operator': '+'}],
'range': [0, 10000]
})['data']['items']:
api.edit({
'id': item['id'],
'title': '%s %s' % (n, item['title']),
})
n += 1