upload-scripts
upload-scripts copied to clipboard
JSONDecodeError occurs when Image Description tag is not in JSON format
When I uploaded photos that did not have an Image Description tag in JSON format, I got a json.decoder.JSONDecodeError as shown in the traceback below.
Traceback (most recent call last):
File "./osc_tools.py", line 243, in <module>
main()
File "./osc_tools.py", line 24, in main
args.func(args)
File "./osc_tools.py", line 95, in upload_command
sequences = discoverer.discover(path)
File "/home/pi/src/upload-scripts/osc_discoverer.py", line 113, in discover
sequences = sequences + self.discover(full_path)
File "/home/pi/src/upload-scripts/osc_discoverer.py", line 114, in discover
sequence = self.create_sequence(path)
File "/home/pi/src/upload-scripts/osc_discoverer.py", line 129, in create_sequence
(visual_data, data_type) = self.visual_data.discover(path)
File "/home/pi/src/upload-scripts/visual_data_discover.py", line 50, in discover
photo = cls._photo_from_path(os.path.join(path, file_path))
File "/home/pi/src/upload-scripts/visual_data_discover.py", line 130, in _photo_from_path
exif_parser.next_item_with_class(PhotoMetadata))
File "/home/pi/src/upload-scripts/parsers/exif/exif.py", line 47, in next_item_with_class
return self._photo_item(self.tags)
File "/home/pi/src/upload-scripts/parsers/exif/exif.py", line 171, in _photo_item
gps = self._gps_item(tags_data)
File "/home/pi/src/upload-scripts/parsers/exif/exif.py", line 133, in _gps_item
gps.timestamp = self._gps_timestamp(tags_data)
File "/home/pi/src/upload-scripts/parsers/custom_data_parsers/custom_mapillary.py", line 21, in _gps_timestamp
description = json.loads(description)
File "/usr/lib/python3.7/json/__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.7/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)