From 9f0068958d78d9b92279486fa2fba93556a17247 Mon Sep 17 00:00:00 2001 From: Peter Date: Sat, 30 Dec 2017 14:47:34 +0100 Subject: [PATCH] Fix grep not working with "-" in URLs and checking if URLs are available at premiumize --- premiumize-cli.sh | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/premiumize-cli.sh b/premiumize-cli.sh index a56cb23..e750a02 100755 --- a/premiumize-cli.sh +++ b/premiumize-cli.sh @@ -6,7 +6,7 @@ pass="[USERPASS]" case "$1" in *.dlc) - links=$(curl -s 'http://dcrypt.it/decrypt/paste' --data-urlencode "content@$1" |jq -r .success.links|grep -Po '[\w\d:/\.]+') + links=$(curl -s 'http://dcrypt.it/decrypt/paste' --data-urlencode "content@$1" |jq -r .success.links|grep -Po ' "\K[^"]*') ;; *.links) links=$(cat $1) @@ -19,15 +19,21 @@ case "$1" in echo "A File containing a list of URLs" exit 1 esac - - for i in $links; do JSON=$(curl -s "https://api.premiumize.me/pm-api/v1.php?method=directdownloadlink¶ms\[login\]=$id¶ms\[pass\]=$pass¶ms\[link\]=$i") - LOCATION=$(echo $JSON | jq -r .result.location) - NAME=$(echo $JSON | jq -r .result.filename) + STATUS=$(echo $JSON | jq -r .status) + MESSAGE=$(echo $JSON | jq -r .statusmessage) - echo $NAME - curl --progress-bar -o $NAME $LOCATION -done + if [ $STATUS == 200 ] + then + LOCATION=$(echo $JSON | jq -r .result.location) + NAME=$(echo $JSON | jq -r .result.filename) + + echo $NAME + curl --progress-bar -o $NAME $LOCATION + else + echo "Error:" $MESSAGE + fi +done \ No newline at end of file