Skip to content

Commit de5b635

Browse files
committed
getty-add: log 404
1 parent 67853dd commit de5b635

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

library/createdb/getty_add.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,9 @@ def objects_extract(args, j):
139139
description = object_description["content"]
140140
description += ";".join(d["content"] for d in object_description["subject_to"] for d in d["subject_of"])
141141

142-
author = None
143-
if j["produced_by"].get("referred_to_by"):
144-
author = iterables.find_dict_value(
145-
j["produced_by"]["referred_to_by"], _label="Artist/Maker (Producer) Description"
146-
).get("content")
142+
author = traverse_obj(j, ["produced_by", "referred_to_by"])
143+
if author:
144+
author = iterables.find_dict_value(author, _label="Artist/Maker (Producer) Description").get("content")
147145

148146
# TODO: deprecated but I don't want to make another HTTP call... calling their bluff
149147
image_path = [
@@ -165,7 +163,7 @@ def objects_extract(args, j):
165163

166164
d = {
167165
"path": image_path or None,
168-
"name": j["_label"],
166+
"title": j["_label"],
169167
"types": "; ".join(set(d["_label"] for d in j["classified_as"]) - ignore_types),
170168
"description": description,
171169
"culture": iterables.find_dict_value(j["referred_to_by"], _label="Culture Statement").get("content"),
@@ -207,7 +205,9 @@ def update_objects(args):
207205
page_data = getty_fetch(unknown_object)
208206
if page_data:
209207
images = objects_extract(args, page_data)
210-
args.db["media"].insert_all(images, alter=True, replace=True, pk="id")
208+
args.db["media"].insert_all(images, alter=True, pk="id")
209+
else:
210+
args.db["media"].insert({'title': '404 Not Found', 'object_path': unknown_object}, alter=True, pk="id")
211211

212212

213213
def getty_add():

library/mediafiles/process_media.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ def collect_media(args) -> list[dict]:
128128
def check_shrink(args, m) -> list:
129129
m["ext"] = path_utils.ext(m["path"])
130130
filetype = (m.get("type") or "").lower()
131+
132+
if not m["size"]: # empty or deleted file
133+
return []
134+
131135
if (
132136
(filetype and (filetype.startswith("audio/") or " audio" in filetype))
133137
or m["ext"] in consts.AUDIO_ONLY_EXTENSIONS

0 commit comments

Comments
 (0)