Skip to content

Instantly share code, notes, and snippets.

@trodemaster
Last active January 2, 2016 01:59
Show Gist options
  • Save trodemaster/8234205 to your computer and use it in GitHub Desktop.
Save trodemaster/8234205 to your computer and use it in GitHub Desktop.
Stevens Pass - download webcam images and set as both desktops
#!/bin/bash
# Download webcam image and archive
#
jpg_name_base=base`date "+%y%m%d-%H%M"`.jpg
jpg_name_sky=sky`date "+%y%m%d-%H%M"`.jpg
jpg_dirBase=/Volumes/Zen/images/StevensBase13-14/
jpg_dirSky=/Volumes/Zen/images/StevensSky13-14/
dtpat1=$jpg_dirBase$jpg_name_base
dtpat2=$jpg_dirSky$jpg_name_sky
jpg_url1=http://stevenspass.com/cams/base/
jpg_url2=http://stevenspass.com/cams/mountain/
log_file=/Users/blake/Library/Logs/stevensdt.log
echo updating webcam image $jpg_name_base $jpg_name_sky >> $log_file
dl_verify_jpeg () {
curl -s $1 -o $2
#echo $2
until [[ `/opt/local/bin/convert $2 -format "%[pixel: u.p{699,465}]" info:` != fractal ]]
do
echo bad jpeg found $2 attempting redownload
rm $2
sleep 20
curl -s $1 -o $2
done
}
dl_verify_jpeg $jpg_url1 $dtpat1
dl_verify_jpeg $jpg_url2 $dtpat2
/usr/bin/automator -D dtpat1=$dtpat1 -D dtpat2=$dtpat2 /Library/Scripts/setdtpat.workflow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment