mirror of https://gitlab.com/bashrc2/epicyon
Obtain exif location data from attachments
parent
b9d9accb14
commit
9bf6f64351
|
|
@ -1970,12 +1970,14 @@ def _receive_new_post_process(self, post_type: str, path: str, headers: {},
|
||||||
continue
|
continue
|
||||||
if property_dict['name'] == "GPSLongitude":
|
if property_dict['name'] == "GPSLongitude":
|
||||||
longitude = property_dict['value']
|
longitude = property_dict['value']
|
||||||
if not isinstance(longitude, float):
|
if not is_float(longitude):
|
||||||
longitude = float(longitude)
|
if isinstance(longitude, str):
|
||||||
|
longitude = float(longitude)
|
||||||
if property_dict['name'] == "GPSLatitude":
|
if property_dict['name'] == "GPSLatitude":
|
||||||
latitude = property_dict['value']
|
latitude = property_dict['value']
|
||||||
if not isinstance(latitude, float):
|
if not is_float(latitude):
|
||||||
longitude = float(latitude)
|
if isinstance(latitude, str):
|
||||||
|
latitude = float(latitude)
|
||||||
if latitude is not None and \
|
if latitude is not None and \
|
||||||
longitude is not None:
|
longitude is not None:
|
||||||
osm_domain = 'osm.org'
|
osm_domain = 'osm.org'
|
||||||
|
|
|
||||||
52
maps.py
52
maps.py
|
|
@ -276,6 +276,58 @@ def get_location_from_post(post_json_object: {}) -> str:
|
||||||
elif isinstance(locn2['address'], dict):
|
elif isinstance(locn2['address'], dict):
|
||||||
locn_address = \
|
locn_address = \
|
||||||
_location_address_from_dict(locn2['address'])
|
_location_address_from_dict(locn2['address'])
|
||||||
|
|
||||||
|
if not locn_exists:
|
||||||
|
# is the location contained within attachments as exif data?
|
||||||
|
# see FEP-ee3a
|
||||||
|
# https://codeberg.org/fediverse/fep/src/branch/main/
|
||||||
|
# fep/ee3a/fep-ee3a.md
|
||||||
|
attachment_list: list[dict] = []
|
||||||
|
if post_obj.get('attachment'):
|
||||||
|
if isinstance(post_obj['attachment'], list):
|
||||||
|
attachment_list = post_obj['attachment']
|
||||||
|
for attach_dict in attachment_list:
|
||||||
|
if not isinstance(attach_dict, dict):
|
||||||
|
continue
|
||||||
|
if not attach_dict.get('type'):
|
||||||
|
continue
|
||||||
|
if not isinstance(attach_dict['type'], str):
|
||||||
|
continue
|
||||||
|
if attach_dict['type'] != 'Image':
|
||||||
|
continue
|
||||||
|
if not attach_dict.get('exifData'):
|
||||||
|
continue
|
||||||
|
if not isinstance(attach_dict['exifData'], list):
|
||||||
|
continue
|
||||||
|
exif_json = attach_dict['exifData']
|
||||||
|
latitude = None
|
||||||
|
longitude = None
|
||||||
|
for property_dict in exif_json:
|
||||||
|
if not isinstance(property_dict, dict):
|
||||||
|
continue
|
||||||
|
if not property_dict.get('name') or \
|
||||||
|
not property_dict.get('value'):
|
||||||
|
continue
|
||||||
|
if not isinstance(property_dict['name'], str):
|
||||||
|
continue
|
||||||
|
if property_dict['name'] == "GPSLongitude":
|
||||||
|
longitude = property_dict['value']
|
||||||
|
if not is_float(longitude):
|
||||||
|
if isinstance(longitude, str):
|
||||||
|
longitude = float(longitude)
|
||||||
|
if property_dict['name'] == "GPSLatitude":
|
||||||
|
latitude = property_dict['value']
|
||||||
|
if not is_float(latitude):
|
||||||
|
if isinstance(latitude, str):
|
||||||
|
latitude = float(latitude)
|
||||||
|
if latitude is not None and \
|
||||||
|
longitude is not None:
|
||||||
|
locn2 = {
|
||||||
|
'latitude': latitude,
|
||||||
|
'longitude': longitude
|
||||||
|
}
|
||||||
|
locn_exists = True
|
||||||
|
|
||||||
if locn_exists:
|
if locn_exists:
|
||||||
# location geocoordinate
|
# location geocoordinate
|
||||||
osm_domain = 'osm.org'
|
osm_domain = 'osm.org'
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ def meta_data_node_info(base_dir: str,
|
||||||
"FEPs": ["c648", "521a", "8fcf", "4ccd", "c118", "fffd",
|
"FEPs": ["c648", "521a", "8fcf", "4ccd", "c118", "fffd",
|
||||||
"1970", "0837", "7628", "2677", "5e53", "c16b",
|
"1970", "0837", "7628", "2677", "5e53", "c16b",
|
||||||
"5e53", "268d", "b2b8", "9967", "dd4b", "5711",
|
"5e53", "268d", "b2b8", "9967", "dd4b", "5711",
|
||||||
"044f", "82f6"]
|
"044f", "82f6", "ee3a"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nodeinfo
|
return nodeinfo
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue