From b6c2cac271e207352071e9014936809d59aa0ed0 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Mon, 18 Jul 2022 15:29:42 +0100 Subject: Get the current temperature from Jersey Met's usually-more-up-to-date image instead of the JSON. --- index.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index c3caaca..c0bf12d 100644 --- a/index.php +++ b/index.php @@ -15,7 +15,13 @@ $timenow = time(); $json = file_get_contents("https://prodgojweatherstorage.blob.core.windows.net/data/jerseyForecast.json"); $arr_json = json_decode($json, true); -$curtemp = $arr_json['currentTemprature']; +// Try to OCR the current temperature from Jersey Met's usually-more-up-to-date image... +if (!exec('tesseract "https://sojpublicdata.blob.core.windows.net/jerseymet/Town/internet.Temperature1.png" stdout | grep -Eo "[-0-9]+\.[0-9]+°C"', $ocroutput, $ocrretval)) { + $curtemp = $arr_json['currentTemprature']; +} else { + // ...if not, use the JSON output + $curtemp = $ocroutput[0]; +} // Today -- cgit v1.2.3