National Geographic Photo of the Day - Mac Desktop Wallpaper

Note: this post is truly for educational purpose.

National geographic Website publishes photo of the day on a daily basis on http://www.nationalgeographic.com/photography/photo-of-the-day.

Following is a script which will automatically download and apply the image as wallpaper. (Only wallpaper applying is mac script, downloading part is linux.)

#!/bin/sh
currentPath=`pwd`
rm gallery.json
curl 'http://www.nationalgeographic.com/photography/photo-of-the-day/_jcr_content/.gallery.json' -o gallery.json
photoOfTheDay=`cat gallery.json | python -c "import sys, json; gallery = json.load(sys.stdin); print gallery['items'][0]['url'] + gallery['items'][0]['originalUrl']"`
filename=`cat gallery.json | python -c "import sys, json; gallery = json.load(sys.stdin); print gallery['items'][0]['publishDate'] + '.' + gallery['items'][0]['title']"`
echo 'image url = '$photoOfTheDay
filename=${filename//[^[:alnum:]]/}'.jpg'
echo 'file name = archive/'$filename
rm -f "national-geographic-photo-of-the-day.jpg"
curl $photoOfTheDay -o national-geographic-photo-of-the-day.jpg
cp national-geographic-photo-of-the-day.jpg archive/$filename
osascript -e 'tell application "Finder" to set desktop picture to "'$currentPath'/national-geographic-photo-of-the-day.jpg" as POSIX file'

keep this in a NG_PoD.sh file under a directory and apply chmod 755 NG_PoD.sh and execute the file.

Enjoy figuring out everyday automatic execution.

Comments

Popular posts from this blog

NatGeo - Download a month's photos

Xolo Play - Android ROM flashing for Dummies

Android "fastboot" driver installation