Skip to content

Instantly share code, notes, and snippets.

@vivkin
Created July 7, 2016 08:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vivkin/8309d085f23acdce326653386f2b7d4f to your computer and use it in GitHub Desktop.
Save vivkin/8309d085f23acdce326653386f2b7d4f to your computer and use it in GitHub Desktop.
unsplashy. download daily featured pictures from unsplash.com
#!/bin/sh
CATEGORIES="buildings food nature people technology objects"
DESTDIR=~/Pictures/unsplash
RESOLUTION=$(system_profiler SPDisplaysDataType | grep Resolution | sed 's/[^x0-9]//g')
for CATEGORY in ${CATEGORIES}; do
URL=https://source.unsplash.com/category/${CATEGORY}/${RESOLUTION}/daily
IMAGE=$(curl --silent --fail --location --write-out "%{url_effective}" --output /dev/null --url ${URL})
NAME=${IMAGE##*/}
NAME=${NAME%%\?*}
FORMAT=${IMAGE##*fm=}
FORMAT=${FORMAT%%&*}
OUTPUT=${DESTDIR}/${NAME}.${FORMAT}
echo "Downloading ${URL} to ${OUTPUT}"
if [[ ! -f ${OUTPUT} ]]; then
curl -# --fail --create-dirs --output ${OUTPUT} --url ${IMAGE}
else
echo "Already downloaded"
fi
done
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>KeepAlive</key>
<false/>
<key>Label</key>
<string>unsplash</string>
<key>Program</key>
<string>/usr/local/bin/unsplashy</string>
<key>RunAtLoad</key>
<false/>
<key>StartInterval</key>
<integer>43200</integer>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment