From b9fc59b5bde345ac7b628c715ce7d5f97ccdac3c Mon Sep 17 00:00:00 2001 From: St33v Date: Tue, 4 Jan 2022 13:42:08 +1100 Subject: can download and convert when executed manually --- README.md | 22 +++++++++++++++++++++- func/deriveTimeString.sh | 4 ++-- synopticChart.sh | 15 +++++---------- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 9b682c8..5c2a195 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,22 @@ # bomSynoptic -Automoated download and display of synoptic weather charts from the Australian Bureau of Meteorology +Automated download and display of synoptic weather charts from the Australian Bureau of Meteorology + +## Background +(explain motivation and desired results) + +## Current state +Script can download most recent pdf and convert it to a scaled png file + +## todo + + * write a timer service + * 'xdg-open' the png file in its own workspace (in i3 window manager) + + +Files: + +File | Description | Location +-----|-------------|--------- +synopticChart.sh | Top level script | +func/deriveTimeString.sh | Return 'date + time' portion of latest chart for download +func/ diff --git a/func/deriveTimeString.sh b/func/deriveTimeString.sh index 3708265..a09a393 100755 --- a/func/deriveTimeString.sh +++ b/func/deriveTimeString.sh @@ -14,9 +14,9 @@ # This function returns the filename for the most recent chart. DeriveTime() { - nowDate=$(\date -u +%y%m%d) # backslash req. to unalias date to raw format + nowDate=$(\date -u +%Y%m%d) # backslash req. to unalias date to raw format nowTime=$(\date -u +%H%M) # (I have date aliased to date -R) - echo $nowDate$nowTime +# echo $nowDate$nowTime if [ $nowTime -ge 1800 ] ; then fileTime=1800 diff --git a/synopticChart.sh b/synopticChart.sh index 75d2ae2..b18b6e2 100755 --- a/synopticChart.sh +++ b/synopticChart.sh @@ -4,23 +4,18 @@ # See notes about BOM. they don't like scrapers but permit anon FTP # for *personal use* # This script will be called froma timer, once every 6 hours, which is -# how oftern new charts are published. +# how often new charts are published. # # The timer will take care of scheduing the call to the script # todo: check what happens with daylight saving... -# Construct current date and time -# -u for UTC, just get the date portion. -datePart=$(date -u +%Y%m%d) +source func/deriveTimeString.sh -# Now construct the 'time' pertion of the filename. -# It is always 0000, 0600, 1200, or 1800 +dateTime=$(DeriveTime) -timePart=0000 -currentchart=${datePart}-${timePart} -latestChart=IDY00030.${datePart}${timePart}.pdf +latestChart=IDY00030.${dateTime}.pdf curl -o ${latestChart} ftp://ftp.bom.gov.au/anon/gen/fwo/${latestChart} -convert -density 300 ${latestChart} ${currentchart}.png +convert -density 300 ${latestChart} ${dateTime}.png -- cgit v1.3