folderdescription is not returned in find call
This commit is contained in:
parent
ea33cf1d73
commit
8633957c77
1 changed files with 16 additions and 12 deletions
|
@ -22,40 +22,44 @@ class Command(BaseCommand):
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
api = ox.api.signin(options['api'])
|
api = ox.api.signin(options['api'])
|
||||||
|
|
||||||
query = {
|
keys = [
|
||||||
'query': {
|
|
||||||
},
|
|
||||||
'keys': [
|
|
||||||
'id', 'title', 'director', 'summary', 'source', 'sourcedescription', 'date', 'location',
|
'id', 'title', 'director', 'summary', 'source', 'sourcedescription', 'date', 'location',
|
||||||
'country', 'type',
|
'country', 'type',
|
||||||
'duration', 'featuring', 'cinematographer',
|
'duration', 'featuring', 'cinematographer',
|
||||||
'hue', 'saturation', 'lightness',
|
'hue', 'saturation', 'lightness',
|
||||||
'folder', 'folderdescription', 'rightslevel'
|
'folder', 'folderdescription', 'rightslevel'
|
||||||
],
|
]
|
||||||
|
|
||||||
|
query = {
|
||||||
|
'query': {
|
||||||
|
},
|
||||||
|
'keys': ['id'],
|
||||||
'sort': [{'key': 'duration', 'operator': '-'}],
|
'sort': [{'key': 'duration', 'operator': '-'}],
|
||||||
'range': [0, 1000]
|
'range': [0, 1000]
|
||||||
}
|
}
|
||||||
folders = {}
|
folders = {}
|
||||||
for item in api.find(**query)['data']['items']:
|
for item in api.find(**query)['data']['items']:
|
||||||
|
item = api.get(id=item['id'], keys=keys)['data']
|
||||||
if item['rightslevel'] > 0:
|
if item['rightslevel'] > 0:
|
||||||
continue
|
continue
|
||||||
if isinstance(item['folder'], list):
|
if isinstance(item['folder'], list):
|
||||||
print(item['id'])
|
print(item['id'])
|
||||||
|
|
||||||
if item['folder'] not in folders:
|
if item['folder'] not in folders:
|
||||||
description = item['folderdescription'] or item['summary']
|
description = item['folderdescription'] or item.get('summary', '')
|
||||||
folders[item['folder']] = {
|
folders[item['folder']] = {
|
||||||
'title': item['folder'],
|
'title': item['folder'],
|
||||||
'date': item['date'],
|
'date': item.get('date', ''),
|
||||||
'country': item['country'],
|
'country': item.get('country', []),
|
||||||
'featuring': item['featuring'],
|
'featuring': item.get('featuring', []),
|
||||||
'type': item['type'],
|
'type': item['type'],
|
||||||
'description': description,
|
'description': description,
|
||||||
'url': api.url.replace('/api/', '/grid/folder==' + escape(ox.decode_html(item['folder']))),
|
'url': api.url.replace('/api/', '/grid/folder==' + escape(ox.decode_html(item['folder']))),
|
||||||
'items': [],
|
'items': [],
|
||||||
}
|
}
|
||||||
|
|
||||||
del item['folderdescription']
|
del item['folderdescription']
|
||||||
if item['summary'] == folders[item['folder']]['description']:
|
if 'summary' in item and item['summary'] == folders[item['folder']]['description']:
|
||||||
item['summary'] = ''
|
item['summary'] = ''
|
||||||
folders[item['folder']]['items'].append(item)
|
folders[item['folder']]['items'].append(item)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue