Imgur Album Downloader

Friday, June 1, 2012

So instead of going out to buy new computer parts, I decided I'd spend 5 minutes on coding something that i needed. Especially as I personally don't run FireFox on my linux computer, and don't have access to DownThemAll, whenever I'd view an album of beautiful landscapes, I'd have to bookmark it and remember to come back later and download them. Not anymore! My first imgur Album Downloader!

Code:
 #!/bin/bash  
 #----------  
 #Imgur Album Downloader v0.1 \ Linux-Ninjas.com
 #----------  
 function albumtemp()  
 {  
 if [ -e .albumtemp ]; then  
     rm .albumtemp  
 fi  
 }  
 #Check for url + albumtemp  
 if [ $# == "" ]; then  
     echo -n "Url:"  
     read url  
     albumtemp  
 else  
     url="$1"  
     albumtemp  
 fi  
 #echo "url: $url"  
 if [ "$url" == "" ]; then  
     echo "You need to enter a url!"  
 else  
     curl $url -o .albumtemp  
     cat .albumtemp | grep _blank | awk '{print $2}' | cut -d \" -f 2 | xargs wget  
     albumtemp  
 fi  
(Pastebin raw link)

Usage:
 imguralbum url

It will then download all the pictures in the album to the current directory.
Install the script into ~/bin and then add ~/bin to your $PATH variable and you are good to download all the images! :)

4 comments:

Frankcom said...

This will be so damn useful! Thanks man!

herrblau said...

you could just this

curl $url | grep _blank | awk '{print $2}' | cut -d \" -f 2 | xargs wget

to get rid of the temporary file.

GHiver said...

Exactly what I have been needing, thanks for sharing!

Anonymous said...

See: http://pastebin.com/tmCW0X2y

Post a Comment