diff --git a/gofile.io-dl b/gofile.io-dl index 1fbdf10..2bde163 100755 --- a/gofile.io-dl +++ b/gofile.io-dl @@ -2,6 +2,24 @@ set -f # No globbing set -C # No clobbering +printurls= +if [[ "$1" == '--urls' ]] +then + printurls=1 + shift +fi + +dodownload=1 +if [[ "$1" == '--nodl' ]] +then + dodownload= + shift +fi + +function printurl { + [[ "${printurls}" ]] && echo "$1" +} + if [[ $# -ne 1 || ( ! "$1" =~ ^https://gofile\.io/d/[0-9a-zA-Z]+$ && ! "$1" =~ ^https://gofile\.io/\?c=[0-9a-zA-Z]+$ ) ]] then echo 'Usage: gofile.io-dl URL' >&2 @@ -9,6 +27,7 @@ then fi url="$1" +printurl "$url" if [[ "${url}" == *'?c='* ]] then code="${url##*=}" @@ -16,6 +35,7 @@ else code="${url##*/}" fi +printurl "https://apiv2.gofile.io/getUpload?c=${code}" curl -s "https://apiv2.gofile.io/getUpload?c=${code}" | python3 -c 'import json,sys; obj = json.loads(sys.stdin.read().strip())'$'\n''for f in obj["data"]["files"].values():'$'\n'' print(f["size"], f["name"], f["link"])' | \ while read -r size name link do @@ -28,6 +48,12 @@ curl -s "https://apiv2.gofile.io/getUpload?c=${code}" | python3 -c 'import json, exit 1 fi + printurl "${link}" + if [[ -z "${dodownload}" ]] + then + continue + fi + if [[ -e "./${name}" ]] then echo "./${name} already exists" >&2