National Geographic Picture of the Day

Малък скрипт, за който не мога да си препиша заслугите, но ми върши перфектна работа.
Всяка сутрин се стартира в 10:10 и сваля “National Geographic Picture of the Day” в определена папка. И тъй като wallpaper-чето ми се set-ва на всеки 5 мин взимайки random снимка от въпросната папка, всеки ден получавам нова картинка, която чакам да видя с нетърпение 🙂

#!/bin/sh
DATE=`date +%Y-%m-%d`
 
curl http://photography.nationalgeographic.com/photography/photo-of-the-day/ -o pod
 
# look for wallpaper version
if (curl `cat pod | tr '"' '\n' |grep -B 1  'Download wallpaper' | head -1` -o pod2) then
	cat pod2 | tr '"' '\n' |grep -oh 'http://.*exposure.*.jpg' |head -1 | sed 's/0_360x270/0_2560x1600/'
	a=`cat pod2 | tr '"' '\n' |grep -B 4 -A 4 'Desktop Wallpaper' | grep '.jpg' | sed 's/0_1600x1200/0_2560x1600/'`
	curl 'http://photography.nationalgeographic.com/'$a -o $DATE.jpg;
else
	# download the image from here --- in case it is not a wallpaper
	echo "oops... no wallpaper. Get it anyway..."
	a=`cat pod|tr '"' '\n' |grep -A 20 "primary_photo"|grep nationalgeographic.com`
	curl 'http:'$a  -o $DATE.jpg
fi
 
rm pod
rm pod2