"""Location related functionality for BharatPlay.""" import requests import urllib3 def get_ip_location(): """Get user's location from IP address using ipinfo.io.""" try: # Disable SSL warning urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) response = requests.get("https://ipinfo.io/json", verify=False) data = response.json() loc = data.get("loc") if loc: lat_str, lon_str = loc.split(",") return float(lat_str), float(lon_str) except Exception as e: print(f"Error getting location: {e}") return None, None