From e7debdcf46b8d0d5ead6c899593cd8e5929ffe63 Mon Sep 17 00:00:00 2001 From: bbedward Date: Mon, 27 Oct 2025 16:14:07 -0400 Subject: [PATCH] weather: switch to ip-api for auto location --- Services/WeatherService.qml | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/Services/WeatherService.qml b/Services/WeatherService.qml index 4f53ac0d..376cca09 100644 --- a/Services/WeatherService.qml +++ b/Services/WeatherService.qml @@ -322,7 +322,7 @@ Singleton { Process { id: ipLocationFetcher - command: lowPriorityCmd.concat(curlBaseCmd).concat(["http://ipinfo.io/json"]) + command: lowPriorityCmd.concat(curlBaseCmd).concat(["http://ip-api.com/json/"]) running: false stdout: StdioCollector { @@ -335,23 +335,17 @@ Singleton { try { const data = JSON.parse(raw) - const coords = data.loc + + if (data.status === "fail") { + throw new Error("IP location lookup failed") + } + + const lat = parseFloat(data.lat) + const lon = parseFloat(data.lon) const city = data.city - if (!coords || !city) { - throw new Error("Missing location data") - } - - const coordsParts = coords.split(",") - if (coordsParts.length !== 2) { - throw new Error("Invalid coordinates format") - } - - const lat = parseFloat(coordsParts[0]) - const lon = parseFloat(coordsParts[1]) - - if (isNaN(lat) || isNaN(lon)) { - throw new Error("Invalid coordinate values") + if (!city || isNaN(lat) || isNaN(lon)) { + throw new Error("Missing or invalid location data") } root.location = {