Fix an error with photos hashes in the fetch command

This commit is contained in:
Lucas Verney 2018-10-15 08:48:36 +02:00
parent 35c902d3d3
commit dc9392e6f0
1 changed files with 8 additions and 1 deletions

View File

@ -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):