summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2022-07-18 15:29:42 +0100
committerLuke Bratch <luke@bratch.co.uk>2022-07-18 15:29:42 +0100
commitb6c2cac271e207352071e9014936809d59aa0ed0 (patch)
tree7b6adf62ddbf0cbdc9f4a1aa3d083f023393248f
parent4d5bab6ce6cd6dfb5f13ce8bd517c5906d30bad0 (diff)
Get the current temperature from Jersey Met's usually-more-up-to-date image instead of the JSON.
-rw-r--r--index.php8
1 files changed, 7 insertions, 1 deletions
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