Fix export custom child fields failing without included parent field

This commit is contained in:
JonnyWong16 2020-11-27 20:33:04 -08:00
parent f8b00bbd67
commit 9b0caf2a47
No known key found for this signature in database
GPG key ID: B1F1F9807184697A

View file

@ -92,6 +92,14 @@ class Export(object):
'collection': ['children'],
'playlist': ['item']
}
TREE_MEDIA_TYPES = [
('episode', 'season', 'show'),
('track', 'album', 'artist'),
('photo', 'photoalbum'),
('clip', 'photoalbum'),
('children', 'collection'),
('item', 'playlist')
]
METADATA_LEVELS = (0, 1, 2, 3, 9)
MEDIA_INFO_LEVELS = (0, 1, 2, 3, 9)
IMAGE_LEVELS = (0, 1, 2, 9)
@ -1818,6 +1826,15 @@ class Export(object):
else:
self._custom_fields[media_type] = {field}
for tree in self.TREE_MEDIA_TYPES:
for child_media_type, parent_media_type in zip(tree[:-1], tree[1:]):
if child_media_type in self._custom_fields:
plural_child_media_type = self.PLURAL_MEDIA_TYPES[child_media_type]
if parent_media_type in self._custom_fields:
self._custom_fields[parent_media_type].add(plural_child_media_type)
else:
self._custom_fields[parent_media_type] = {plural_child_media_type}
def _parse_custom_field(self, media_type, field):
for child_media_type in self.CHILD_MEDIA_TYPES.get(media_type, []):
plural_key = self.PLURAL_MEDIA_TYPES[child_media_type]