Skip to content

Instantly share code, notes, and snippets.

@viig99
Created July 11, 2012 12:52
Show Gist options
  • Save viig99/3090197 to your computer and use it in GitHub Desktop.
Save viig99/3090197 to your computer and use it in GitHub Desktop.
Download Desktop Wallpapers from fiftyfootshadows.
# Author - Arjun Variar
# Thanks to Ben for introducing me to fiftyfootshadows, Awesome Wallpapers!!
#!/bin/sh
if [[ -z "$TMP" ]]
then
TMP="/private/tmp"
fi
dir="$HOME/fifty_downloads"
function usage () {
cat <<EOF
Usage: fiftyfootshadows -d DIRECTORY_NAME -u
-d directory you want to store your file in, default is $HOME/fifty_downloads
-u If you want to update your list
EOF
exit 0
}
function update () {
rm -rf $TMP/fifty_download_links.txt
link_text=`curl -s --compressed http://fiftyfootshadows.net/category/desktops/ | egrep -io "http:\/\/[^<>]*?\.zip"`
i=2
echo $link_text > $TMP/fifty_download_links.txt
while [[ $link_text ]]
do
link_text=`curl -s --compressed http://fiftyfootshadows.net/category/desktops/page/$i/ | egrep -io "http:\/\/[^<>]*?\.zip"`
echo $link_text >> $TMP/fifty_download_links.txt
i=`expr $i + 1`
done
}
while getopts ":ud:h" opt; do
case $opt in
u ) update ;;
d ) dir=$OPTARG ;;
h ) usage ;;
\?) usage ;;
esac
done
if [ ! -d $dir ]
then
mkdir $dir
fi
if [ ! -f "$TMP/fifty_download_links.txt" ]
then
update
fi
cat -s $TMP/fifty_download_links.txt | tr '[:space:]' '\n' | tr -s '\n' | xargs -P 5 wget -c -N --directory-prefix=$dir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment