Skip to content

Commit bdaf4ec

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

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ def collect_media(args) -> list[dict]:
100100
CALIBRE_INSTALLED = which("ebook-convert")
101101
UNAR_INSTALLED = which("lsar")
102102

103+
if not FFMPEG_INSTALLED:
104+
log.warning('ffmpeg not installed. Video and Audio files will be skipped')
105+
if not IM7_INSTALLED:
106+
log.warning('ImageMagick not installed. Image files will be skipped')
107+
if not CALIBRE_INSTALLED:
108+
log.warning('Calibre not installed. Text files will be skipped')
109+
if not UNAR_INSTALLED:
110+
log.warning('unar not installed. Archives will not be extracted')
111+
103112
default_exts = (
104113
(consts.AUDIO_ONLY_EXTENSIONS if FFMPEG_INSTALLED else set())
105114
| (consts.VIDEO_EXTENSIONS if FFMPEG_INSTALLED else set())
@@ -128,6 +137,10 @@ def collect_media(args) -> list[dict]:
128137
def check_shrink(args, m) -> list:
129138
m["ext"] = path_utils.ext(m["path"])
130139
filetype = (m.get("type") or "").lower()
140+
141+
if not m["size"]: # empty or deleted file
142+
return []
143+
131144
if (
132145
(filetype and (filetype.startswith("audio/") or " audio" in filetype))
133146
or m["ext"] in consts.AUDIO_ONLY_EXTENSIONS

0 commit comments

Comments
 (0)