Browse Source

Add --urls and --nodl options

master
JustAnotherArchivist 3 years ago
parent
commit
77ec76bc04
1 changed files with 26 additions and 0 deletions
  1. +26
    -0
      gofile.io-dl

+ 26
- 0
gofile.io-dl View File

@@ -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


Loading…
Cancel
Save