#!/bin/bash :<&- || { 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 '//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