Skip to content

Commit

Permalink
Merge pull request #50 from arthur-schnitzler/main
Browse files Browse the repository at this point in the history
updates
  • Loading branch information
csae8092 authored Jan 22, 2024
2 parents 3d94cfd + d5cbac4 commit 30064d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion apis_core/apis_entities/management/commands/fetch_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ def handle(self, *args, **kwargs):
)
print(f"start fetching images for {items.count()} persons without images")
for x in tqdm(items[:200]):
x.fetch_image()
try:
x.fetch_image()
except Exception as e:
print(x.id, e)
continue
time.sleep(0.5)
end_time = datetime.now().strftime(settings.PMB_TIME_PATTERN)
report = [os.path.basename(__file__), start_time, end_time]
Expand Down
3 changes: 2 additions & 1 deletion apis_core/apis_metainfo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ def fetch_image(self):
self.img_last_checked = datetime.now()
img_url = fetch_image(wikidata_uri.uri)
if img_url:
self.img_url = img_url
if len(img_url) < 301:
self.img_url = img_url
self.save()
return self

Expand Down

0 comments on commit 30064d8

Please sign in to comment.