use of org.vitrivr.cineast.core.data.entities.MediaObjectMetadataDescriptor in project cineast by vitrivr.
the class JsonMetaDataExtractor method extract.
@Override
public List<MediaObjectMetadataDescriptor> extract(String objectId, Path path) {
File file = path.toFile();
File parent = file.getParentFile();
File jsonFile = new File(parent, file.getName() + ".json");
if (!jsonFile.exists()) {
jsonFile = new File(parent, com.google.common.io.Files.getNameWithoutExtension(file.getName()) + ".json");
}
if (!jsonFile.exists()) {
return new ArrayList<>(0);
}
@SuppressWarnings("unchecked") Map<String, Object> json = jsonProvider.toObject(jsonFile, Map.class);
if (json == null || json.isEmpty()) {
return new ArrayList<>(0);
}
ArrayList<MediaObjectMetadataDescriptor> _return = new ArrayList<>(json.size());
Set<String> keys = json.keySet();
for (String key : keys) {
_return.add(MediaObjectMetadataDescriptor.of(objectId, domain(), key, json.get(key)));
}
return _return;
}
Aggregations