2018-05-31 14:59:17 +00:00
|
|
|
#!/usr/bin/python3
|
2018-05-31 19:32:56 +00:00
|
|
|
import collections
|
2018-05-31 14:59:17 +00:00
|
|
|
import json
|
|
|
|
|
|
|
|
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
|
|
|
|
2018-05-31 19:32:56 +00:00
|
|
|
keywords = collections.Counter()
|
2018-05-31 14:59:17 +00:00
|
|
|
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']:
|
2018-08-10 13:28:36 +00:00
|
|
|
if annotatoin['id'].startswith('BA/'):
|
|
|
|
continue
|
2018-05-31 19:32:56 +00:00
|
|
|
keyword = annotation['value']
|
|
|
|
if ': ' not in keyword:
|
|
|
|
keyword = 'other: ' + keyword
|
|
|
|
keywords[keyword] += 1
|
2018-05-31 14:59:17 +00:00
|
|
|
|
|
|
|
with open('keywords.json', 'w') as fd:
|
2018-05-31 19:32:56 +00:00
|
|
|
json.dump(keywords, fd, indent=4, ensure_ascii=False, sort_keys=True)
|