31 lines
694 B
Python
Executable file
31 lines
694 B
Python
Executable file
#!/usr/bin/python3
|
|
import re
|
|
import sys
|
|
|
|
import ox
|
|
import ox.api
|
|
|
|
site = 'archive.leftove.rs'
|
|
api = ox.api.signin('https://%s/api/' % site)
|
|
|
|
|
|
collection = sys.argv[1]
|
|
prefix = sys.argv[2]
|
|
|
|
for doc in api.findDocuments({
|
|
'query': {
|
|
'conditions': [
|
|
{'key': 'collection', 'operator': '=', 'value': collection}
|
|
],
|
|
'operator': '&'
|
|
},
|
|
'keys': ['id', 'title'],
|
|
'range': [0, 10000]
|
|
})['data']['items']:
|
|
if not doc['title'].startswith(prefix):
|
|
print(doc['id'], doc['title'])
|
|
title = prefix + doc['title']
|
|
api.editDocument({
|
|
'id': doc['id'],
|
|
'title': title
|
|
})
|