IsraelTorres icon

getimguralbum.sh

IsraelTorres | PRO | 03/24/12 07:00:44 PM UTC | 0 ⭐ | 348 👁️ | Never ⏰ | []
Bash |

1.1 KB

|

None

|

0 👍

/

0 👎

#!/bin/bash
:<<israeltorres_comment_block
 
./getimguralbum.sh
Israel Torres
2012-03-23
Simple known methods to retrieve imgur albums
 
Mac OS X 10.7.3 11D50d 
Darwin Kernel Version 11.3.0
GNU bash, version 3.2.48(1)-release 
 
israeltorres_comment_block
 
#required app check
rqdapp='curl'
hash $rqdapp 2>&- || { echo >&2 "$rqdapp binary not found - aborting"; exit 1; }
#
if [ ! $# -lt 1 ]; then
IMGURL=$1; DLDIR=$(date +%s); mkdir $DLDIR; cd $DLDIR
echo "Trying Method 1"
curl "$IMGURL#0" -s | grep 'alt="" src=' | sed 's/.*src="\(.*\)".*/\1/g;s/s\./\./g' | awk '{print $1 " -O -s";}' | xargs curl
if  [ ! "$(ls -A .)" ]; then #check if $DLDIR is empty from the inside
    echo -e "Method 1 Failed\nTrying Method 2"
    curl "$IMGURL#0" -s | grep '<a class=\"zoom\" href=\"http:' | sed 's/\<a class=\"zoom\" href=\"//g;s/\"\>//g;s///g;s/s\./\./g' | awk '{print $1 " -O -s";}' | xargs curl
    if  [ "$(ls -A .)" ]; then
        echo "Method 2 Passed"
    else
        echo "Method 2 Failed"
    fi
else
    echo "Method 1 Passed"
fi
 
else
    echo "usage: $0 'imgur url'"
    echo "example: $0 https://imgur.com/a/hEbVS"
fi
#eof

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎