add volume
This commit is contained in:
parent
bab1c3859a
commit
2de2e27975
3 changed files with 53 additions and 13 deletions
33
cleanup/search_replace.py
Executable file
33
cleanup/search_replace.py
Executable file
|
|
@ -0,0 +1,33 @@
|
|||
#!/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]
|
||||
search = sys.argv[2]
|
||||
replace = sys.argv[3]
|
||||
|
||||
for doc in api.findDocuments({
|
||||
'query': {
|
||||
'conditions': [
|
||||
{'key': 'collection', 'operator': '=', 'value': collection}
|
||||
],
|
||||
'operator': '&'
|
||||
},
|
||||
'keys': ['id', 'title'],
|
||||
'range': [0, 10000]
|
||||
})['data']['items']:
|
||||
title = doc['title'].replace(search, replace)
|
||||
if title != doc['title']:
|
||||
print(doc['id'], doc['title'])
|
||||
print('\t->', title)
|
||||
api.editDocument({
|
||||
'id': doc['id'],
|
||||
'title': title
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue