def metadata_as_dict(metadata):
    return {item.key: (len(item.values) > 1 and [v.value for v in item.
        values] or item.values[0].value) for item in metadata if item.values}
Hachoir - Retrieving data from a group