Browse Source

Add support for password-protected folders

master
JustAnotherArchivist 2 years ago
parent
commit
696e221fc1
1 changed files with 9 additions and 2 deletions
  1. +9
    -2
      gofile.io-dl

+ 9
- 2
gofile.io-dl View File

@@ -22,13 +22,14 @@ function printurl {
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]+$ ) ]]
if [[ ( $# -ne 1 && $# -ne 2 ) || ( ! "$1" =~ ^https://gofile\.io/d/[0-9a-zA-Z]+$ && ! "$1" =~ ^https://gofile\.io/\?c=[0-9a-zA-Z]+$ ) ]]
then
echo 'Usage: gofile.io-dl [--urls] [--nodl] URL' >&2
echo 'Usage: gofile.io-dl [--urls] [--nodl] URL [PASSWORD]' >&2
exit 1
fi

url="$1"
password="$2"
printurl "$url"
if [[ "${url}" == *'?c='* ]]
then
@@ -39,6 +40,12 @@ fi

folderUrl="https://api.gofile.io/getFolder?folderId=${code}"
printurl "${folderUrl}"
if [[ "${password}" ]]
then
password="$(echo -n "${password}" | sha256sum | sed 's,\s.*$,,')"
folderUrl="${folderUrl}&password=${password}&cache=true"
printurl "${folderUrl}"
fi
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


Loading…
Cancel
Save