Browse Source

Basic error checks

master
JustAnotherArchivist 2 years ago
parent
commit
53bfe468bf
1 changed files with 4 additions and 2 deletions
  1. +4
    -2
      gofile.io-dl

+ 4
- 2
gofile.io-dl View File

@@ -1,6 +1,8 @@
#!/bin/bash
set -f # No globbing
set -C # No clobbering
set -e
set -o pipefail

printurls=
if [[ "$1" == '--urls' ]]
@@ -17,7 +19,7 @@ then
fi

function printurl {
[[ "${printurls}" ]] && echo "$1"
if [[ "${printurls}" ]]; then echo "$1"; fi
}

if [[ $# -ne 1 || ( ! "$1" =~ ^https://gofile\.io/d/[0-9a-zA-Z]+$ && ! "$1" =~ ^https://gofile\.io/\?c=[0-9a-zA-Z]+$ ) ]]
@@ -37,7 +39,7 @@ fi

folderUrl="https://api.gofile.io/getFolder?folderId=${code}"
printurl "${folderUrl}"
curl -s "${folderUrl}" | python3 -c 'import json,sys; obj = json.loads(sys.stdin.read().strip())'$'\n''for f in obj["data"]["contents"].values():'$'\n'' print(f["size"], f["md5"], f["name"], f["link"])' | \
curl -s --fail "${folderUrl}" | python3 -c 'import json,sys; obj = json.loads(sys.stdin.read().strip())'$'\n''for f in obj["data"]["contents"].values():'$'\n'' print(f["size"], f["md5"], f["name"], f["link"])' | \
while read -r size md5 name link
do
if [[ "${name}" == *'/'* || "${link}" == *' '* || ! "${link}" =~ ^https://((srv-)?file[0-9]+|srv-store[0-9]+)\.gofile\.io/download/ ]]


Loading…
Cancel
Save