Skip to content

Instantly share code, notes, and snippets.

@dtrailin
Created October 6, 2012 06:37
Show Gist options
  • Select an option

  • Save dtrailin/3844234 to your computer and use it in GitHub Desktop.

Select an option

Save dtrailin/3844234 to your computer and use it in GitHub Desktop.
Imgur downloader
function ImgurDir {
if [ -d ~/imgur\ albums ]
then
cd ~/imgur\ albums
else
mkdir ~/imgur\ albums
cd ~/imgur\ albums
fi
}
function readAlbum {
echo "what album do you want?"
read album
}
function GetLinks {
wget -q www.imgur.com/a/$album
links=$(grep -o \<img\ id=\"thumb-..... $album)
rm $album
}
function subdir {
if [ -d $album ]
then
cd $album
rm -rf
else
mkdir $album
cd $album
fi
}
function GetImg {
COUNTER=0
printf %s "$links" | while IFS= read -r line
do
let COUNTER=COUNTER+1
shorter=${line:15}
wget -q www.i.imgur.com/$shorter.gif
echo "getting image" $COUNTER
done
}
function main {
ImgurDir
long=$USERNAME
short=${long:0:1}
echo "Welcome" "${short^^}""${long:1}" "to Denis' Imgur album downloading script!(currently only supports \"Blog Layout\")"
readAlbum
subdir
GetLinks
GetImg
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment