-
-
Save pugson/dfd3a080370c2eec0e5d to your computer and use it in GitHub Desktop.
This file contains 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
# 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