diff options
author | Luke Bratch <luke@bratch.co.uk> | 2022-07-18 15:29:42 +0100 |
---|---|---|
committer | Luke Bratch <luke@bratch.co.uk> | 2022-07-18 15:29:42 +0100 |
commit | b6c2cac271e207352071e9014936809d59aa0ed0 (patch) | |
tree | 7b6adf62ddbf0cbdc9f4a1aa3d083f023393248f /index.php | |
parent | 4d5bab6ce6cd6dfb5f13ce8bd517c5906d30bad0 (diff) |
Get the current temperature from Jersey Met's usually-more-up-to-date image instead of the JSON.
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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 |