#!/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
0 B
|👍
/👎