folderdescription is not returned in find call

This commit is contained in:
j 2021-11-24 17:10:25 +01:00
parent ea33cf1d73
commit 8633957c77

View file

@ -22,40 +22,44 @@ class Command(BaseCommand):
def handle(self, *args, **options):
api = ox.api.signin(options['api'])
keys = [
'id', 'title', 'director', 'summary', 'source', 'sourcedescription', 'date', 'location',
'country', 'type',
'duration', 'featuring', 'cinematographer',
'hue', 'saturation', 'lightness',
'folder', 'folderdescription', 'rightslevel'
]
query = {
'query': {
},
'keys': [
'id', 'title', 'director', 'summary', 'source', 'sourcedescription', 'date', 'location',
'country', 'type',
'duration', 'featuring', 'cinematographer',
'hue', 'saturation', 'lightness',
'folder', 'folderdescription', 'rightslevel'
],
'keys': ['id'],
'sort': [{'key': 'duration', 'operator': '-'}],
'range': [0, 1000]
}
folders = {}
for item in api.find(**query)['data']['items']:
item = api.get(id=item['id'], keys=keys)['data']
if item['rightslevel'] > 0:
continue
if isinstance(item['folder'], list):
print(item['id'])
if item['folder'] not in folders:
description = item['folderdescription'] or item['summary']
description = item['folderdescription'] or item.get('summary', '')
folders[item['folder']] = {
'title': item['folder'],
'date': item['date'],
'country': item['country'],
'featuring': item['featuring'],
'date': item.get('date', ''),
'country': item.get('country', []),
'featuring': item.get('featuring', []),
'type': item['type'],
'description': description,
'url': api.url.replace('/api/', '/grid/folder==' + escape(ox.decode_html(item['folder']))),
'items': [],
}
del item['folderdescription']
if item['summary'] == folders[item['folder']]['description']:
if 'summary' in item and item['summary'] == folders[item['folder']]['description']:
item['summary'] = ''
folders[item['folder']]['items'].append(item)