Last active
August 29, 2015 13:57
-
-
Save ryonsherman/9652341 to your computer and use it in GitHub Desktop.
Bing wallpaper downloader
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
#!/usr/bin/env sh | |
LOC="en-US" | |
for RES in _1920x1200 _1366x768 _1280x720 _1024x768; do | |
XML="http://www.bing.com/HPImageArchive.aspx?format=xml&idx=0&n=1&mkt=${LOC}" | |
URL="http://www.bing.com$(echo $(curl -s ${XML}) | grep -oP "<urlBase>(.*)</urlBase>" | cut -d ">" -f 2 | cut -d "<" -f 1)${RES}.jpg" | |
IMG=${URL##*/} | |
curl -s -o /tmp/$IMG $URL | |
file /tmp/$IMG | grep -i HTML && rm -rf /tmp/$IMG && continue | |
break | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment