Skip to content

Instantly share code, notes, and snippets.

@pugson
Forked from viig99/fiftyfootshadows.sh
Last active August 29, 2015 14:13
Show Gist options
  • Save pugson/dfd3a080370c2eec0e5d to your computer and use it in GitHub Desktop.
Save pugson/dfd3a080370c2eec0e5d to your computer and use it in GitHub Desktop.
# 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/Wallpapers/fiftyfootshadows"
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