From 8633957c77ae078f023ba77ba9937722c9c62856 Mon Sep 17 00:00:00 2001 From: j Date: Wed, 24 Nov 2021 17:10:25 +0100 Subject: [PATCH] folderdescription is not returned in find call --- app/video/management/commands/load_titles.py | 28 +++++++++++--------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/app/video/management/commands/load_titles.py b/app/video/management/commands/load_titles.py index 9a32b9b..9e5d61f 100644 --- a/app/video/management/commands/load_titles.py +++ b/app/video/management/commands/load_titles.py @@ -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)