Created
May 25, 2015 09:06
-
-
Save ninehills/45e94296cb4556f9bdf7 to your computer and use it in GitHub Desktop.
Auto download bing wallpapers.
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 bash | |
PICTURE_DIR="$HOME/Pictures/bing-wallpapers/" | |
mkdir -p $PICTURE_DIR | |
BING_URL="http://global.bing.com/?FORM=HPCNEN&setmkt=en-us&setlang=en-us#" | |
urls=( $(curl -s $BING_URL | \ | |
grep -Eo "url:'.*?'" | \ | |
sed -e "s/url:'\([^']*\)'.*/http:\/\/bing.com\1/" | \ | |
sed -e "s/\\\//g") ) | |
for p in ${urls[@]}; do | |
filename=$(echo $p|sed -e "s/.*\/\(.*\)/\1/") | |
if [ ! -f $PICTURE_DIR/$filename ]; then | |
echo "Downloading: $filename ..." | |
curl -Lo "$PICTURE_DIR/$filename" $p | |
else | |
echo "Skipping: $filename ..." | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ crontab -l
min hour mday month wday command
20 9,12,15,19,22 * * * sh -x
/bin/bing-wallpaper.sh &>/bin/bing-wallpaper.log