summaryrefslogtreecommitdiff
path: root/local
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2017-03-06 22:32:14 +1300
committerDavid Phillips <david@sighup.nz>2017-03-06 22:32:14 +1300
commit05ed95b9221dece8cae9bd6021d02375c26ee491 (patch)
tree9dd5239c4b5a756814107c8e29b853de57916eee /local
parent21a61fb639e8434fff924f3b862ebd8014f02c60 (diff)
downloaddotfiles-05ed95b9221dece8cae9bd6021d02375c26ee491.tar.xz
Only download if old price
Diffstat (limited to 'local')
-rwxr-xr-xlocal/bin/grab-spot8
1 files changed, 5 insertions, 3 deletions
diff --git a/local/bin/grab-spot b/local/bin/grab-spot
index 3939d72..0450c8e 100755
--- a/local/bin/grab-spot
+++ b/local/bin/grab-spot
@@ -8,6 +8,8 @@ if [ -z $2 ]; then
exit
fi
-rate=$(curl "http://rate-exchange-1.appspot.com/currency?from=$1&to=$2" | jshon -e rate)
-
-echo "$1$2: $rate" > ~/.cache/"$1$2"
+# Only bother downloading if it's more than 3 hours old
+if [ $(find ~/.cache/"$1$2" -mmin +180) ] ; then
+ rate=$(curl "http://rate-exchange-1.appspot.com/currency?from=$1&to=$2" | jshon -e rate)
+ echo "$1$2: $rate" > ~/.cache/"$1$2"
+fi