Skip to content

Commit

Permalink
unique_images: work with no metadata.json
Browse files Browse the repository at this point in the history
  • Loading branch information
dale-wahl committed Jan 9, 2025
1 parent 1a31106 commit 5d026a7
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions processors/filtering/unique_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,16 @@ def process(self):

new_metadata = {}
inverse_hashmap = {v: k for k, v in hash_map.items()}
for url, item in metadata.items():
if item["filename"] in inverse_hashmap:
new_metadata[inverse_hashmap[item["filename"]]] = {
**item,
"hash": inverse_hashmap[item["filename"]],
"hash_type": self.parameters.get("hash-type")
}
if metadata:
for url, item in metadata.items():
if item["filename"] in inverse_hashmap:
new_metadata[inverse_hashmap[item["filename"]]] = {
**item,
"hash": inverse_hashmap[item["filename"]],
"hash_type": self.parameters.get("hash-type")
}
else:
new_metadata = {hash_map[k]: {"filename": hash_map[k], "hash": k, "hash_type": self.parameters.get("hash-type")} for k in hash_map}

with staging_area.joinpath(".metadata.json").open("w") as outfile:
json.dump(new_metadata, outfile)
Expand Down

0 comments on commit 5d026a7

Please sign in to comment.