pandora_cms/ontology/update_keywords.py

31 lines
634 B
Python
Raw Normal View History

2018-05-31 14:59:17 +00:00
#!/usr/bin/python3
import getpass
import json
import sys
import ox
2018-05-31 19:21:34 +00:00
import ox.api
2018-05-31 14:59:17 +00:00
site = 'pandora.cinemusespace.com'
2018-05-31 19:21:34 +00:00
api = ox.api.signin('https://%s/api/' % site)
2018-05-31 14:59:17 +00:00
keywords = set()
for annotation in api.findAnnotations({
'query': {
'conditions': [{
'key': 'layer',
'value': 'keywords',
'operator': '=='
}],
'operator': '&'
},
'keys': ['id', 'in', 'out', 'value', 'user', 'created'],
'range': [0, 500000]
})['data']['items']:
keywords.add(annotation['value'])
with open('keywords.json', 'w') as fd:
json.dump(list(sorted(keywords)), fd, indent=4)