Posts

Showing posts from 2017

NatGeo - Download a month's photos

NG_download_month.sh #!/bin/sh CYAN='\033[0;36m' YELLOW='\033[1;33m' NC='\033[0m' # No Color currentPath=`pwd` currentYear=`date +"%Y"` currentMonth=`date +"%m"` downloadYear=$1 downloadMonth=$2 force=$3 if [ $# -lt 2 ] then echo "YEAR and MONTH arguments required; eg: ./NG_download_month.sh 2017 06" exit fi jsonFilename="gallery."$downloadYear"-"$downloadMonth".json" if [ $currentYear -eq $downloadYear -a $currentMonth -eq $downloadMonth ] then echo "${CYAN}Current month${NC} images get update. Deleting file: $jsonFilename" rm $jsonFilename elif [ $force == '-f' ] then echo "Force deleting file: $jsonFilename" rm $jsonFilename fi if [ ! -f $jsonFilename ] then echo "${YELLOW}$jsonFilename${NC} unavailable. Downloading..." # BASE_URL="http://www.nationalgeographic.com/photography/photo-of-the-day/_jcr_content" BASE_URL="https://www.

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