From f753d7277f6e0186a60b2a8ab2a91966d9e7d6e6 Mon Sep 17 00:00:00 2001 From: kempersc Date: Tue, 30 Dec 2025 03:45:29 +0100 Subject: [PATCH] Add country code extraction for location validation in Google Places API --- scripts/enrich_cities_google.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/enrich_cities_google.py b/scripts/enrich_cities_google.py index 3b9985f4db..8902f7a295 100755 --- a/scripts/enrich_cities_google.py +++ b/scripts/enrich_cities_google.py @@ -129,6 +129,7 @@ def extract_location_from_google(place: dict) -> dict: 'formatted_address': None, 'place_id': None, 'website': None, + 'country_code': None, # Added for country validation } if not place: @@ -146,6 +147,7 @@ def extract_location_from_google(place: dict) -> dict: for comp in components: types = comp.get('types', []) long_name = comp.get('longText', '') + short_name = comp.get('shortText', '') if 'locality' in types: result['city'] = long_name @@ -153,6 +155,9 @@ def extract_location_from_google(place: dict) -> dict: result['region'] = long_name elif 'sublocality_level_1' in types and not result['city']: result['city'] = long_name + elif 'country' in types: + # Extract country code for validation + result['country_code'] = short_name return result