Sirius' blog


The establishment of repoistory bing-wallpaper-collect

The purpose of this repoistory

The backgrounds of bing is always good, and it refresh every day, I use them as wallpaper, log-in background, grub background, and so on. I always download them manually, It may not very troublesome, but my touchpad’s right key broken recently, so I decided to download it automatically.

And I think: why not push it on github? It can also published to my github page, and then people can browse them, and download their favorite, so I established this repoistory.

The implement of auto download

I wrote a simple script first, and it can automatically download today’s bing wallpaper. However, I need to run it with cron, so I need to modify it to fit my need.


[[ -z $1 ]] && workdir='/root/git/bing-wallpaper/assets/' || workdir=$1
cd $workdir
text=`wget -O- $site`
if [[ -z $text ]]; then
	echo "connecting to $site failed!" | mail -s "bing-wallpaper" root
url=`echo $text | grep img={url | sed -n 's#.*\(/az/[^"]*\).*#\1#;p'`
filename=`echo $url | awk -F/ '{print $NF}'`
echo file:$site$url
if [[ -e $filename ]]; then
	echo "file exist!" | mail -s "bing-wallpaper" root
	echo "file exist!"
	wget -O $workdir$filename https://$site/$url
	git add $filename
	git commit -a -m `date -I`
	git push origin master

The script is based on string processing, and I extract the background image address from the source code of, I don’t know it will always work properly or not, if the execute get into trouble, I will receive e-mail, I will let it run until I receive it.

I run it in my server by cron, and I also have local repoistory, I can pull from server when I need.

Publish to GitHub Page

There are too many wallpapers, so it’s not easy to select, so I decide to list it in my GitHub Page. But I met many problems.

After all, I hope this repoistory can make sense.