From dc9392e6f048aea5227a9b899e580d18a6322a61 Mon Sep 17 00:00:00 2001 From: "Phyks (Lucas Verney)" Date: Mon, 15 Oct 2018 08:48:36 +0200 Subject: [PATCH] Fix an error with photos hashes in the fetch command --- flatisfy/tools.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/flatisfy/tools.py b/flatisfy/tools.py index 53e449c..75efade 100644 --- a/flatisfy/tools.py +++ b/flatisfy/tools.py @@ -15,6 +15,7 @@ import math import re import time +import imagehash import mapbox import requests import unidecode @@ -128,7 +129,13 @@ class DateAwareJSONEncoder(json.JSONEncoder): def default(self, o): # pylint: disable=locally-disabled,E0202 if isinstance(o, (datetime.date, datetime.datetime)): return o.isoformat() - return json.JSONEncoder.default(self, o) + try: + return json.JSONEncoder.default(self, o) + except TypeError: + # Discard image hashes + if isinstance(o, imagehash.ImageHash): + return None + raise def pretty_json(data):