Created
July 7, 2016 08:51
-
-
Save vivkin/8309d085f23acdce326653386f2b7d4f to your computer and use it in GitHub Desktop.
unsplashy. download daily featured pictures from unsplash.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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