Skip to content

Instantly share code, notes, and snippets.

@rokibhasansagar
Forked from shawnli87/download_gofile.sh
Created January 22, 2024 10:39
Show Gist options
  • Select an option

  • Save rokibhasansagar/2f9c241ec6a16acb7a76053281a34d5c to your computer and use it in GitHub Desktop.

Select an option

Save rokibhasansagar/2f9c241ec6a16acb7a76053281a34d5c to your computer and use it in GitHub Desktop.

Revisions

  1. @shawnli87 shawnli87 revised this gist May 20, 2023. 1 changed file with 43 additions and 6 deletions.
    49 changes: 43 additions & 6 deletions download_gofile.sh
    Original file line number Diff line number Diff line change
    @@ -1,23 +1,60 @@
    #!/bin/bash

    id=$(sed 's|.*gofile.io/d/||g' <<< "$1")
    url="$1"

    #prompt for url if not provided
    until [ ! -z "$url" ] ; do
    read -p "url=" url
    done

    id=$(sed 's|.*gofile.io/d/||g' <<< "$url")
    echo "Downloading $id"

    #get guest account token for url and cookie
    token=$(curl -s 'https://api.gofile.io/createAccount' | jq -r '.data.token' 2>/dev/null)
    [ "$?" -ne 0 ] && echo "Creating guest account failed, please try again later"

    #get website token for url
    websiteToken=$(curl -s 'https://gofile.io/dist/js/alljs.js' | grep websiteToken | awk '{ print $3 }' | jq -r)
    [ "$?" -ne 0 ] && echo "Getting website token failed, please try again later"

    #get content info from api
    resp=$(curl 'https://api.gofile.io/getContent?contentId='"$id"'&token='"$token"'&websiteToken=12345&cache=true' 2>/dev/null)
    resp=$(curl 'https://api.gofile.io/getContent?contentId='"$id"'&token='"$token"'&websiteToken='"$websiteToken"'&cache=true' 2>/dev/null)
    code="$?"

    #prompt for password if required
    if [[ $(jq -r '.status' <<< "$resp" 2>/dev/null) == "error-passwordRequired" ]] ; then
    until [ ! -z "$password" ] ; do
    read -p "password=" password
    password=$(printf "$password" | sha256sum | cut -d' ' -f1)

    resp=$(curl 'https://api.gofile.io/getContent?contentId='"$id"'&token='"$token"'&websiteToken='"$websiteToken"'&cache=true&password='"$password" 2>/dev/null)
    code="$?"
    done
    fi

    #verify content info was retrieved successfully
    [ "$code" -ne 0 ] && echo "URL unreachable, check provided link" && exit 1

    #create download folder
    mkdir "$id" 2>/dev/null
    cd "$id"

    #load the page once so download links don't get redirected
    curl -H 'Cookie: accountToken='"$token" "$1" -o /dev/null 2>/dev/null
    curl -H 'Cookie: accountToken='"$token" "$url" -o /dev/null 2>/dev/null
    [ "$?" -ne 0 ] && echo "Loading page failed, check provided link"

    for i in $(jq '.data.contents | keys | .[]' <<< "$resp"); do
    name=$(jq -r '.data.contents['"$i"'].name' <<< "$resp")
    url=$(jq -r '.data.contents['"$i"'].link' <<< "$resp")
    echo
    echo "Downloading $name"
    curl -H 'Cookie: accountToken='"$token" "$url" -o "$name"

    #download file if not already downloaded
    if [ ! -f "$name" ] ; then
    echo
    echo "Downloading $name"
    curl -H 'Cookie: accountToken='"$token" "$url" -o "$name"
    [ "$?" -ne 0 ] && echo "Downloading ""$filename"" failed, please try again later" && rm "$filename"
    fi
    done

    echo
  2. @shawnli87 shawnli87 revised this gist Aug 25, 2022. 1 changed file with 3 additions and 8 deletions.
    11 changes: 3 additions & 8 deletions download_gofile.sh
    Original file line number Diff line number Diff line change
    @@ -6,26 +6,21 @@ echo "Downloading $id"
    #get guest account token for url and cookie
    token=$(curl -s 'https://api.gofile.io/createAccount' | jq -r '.data.token' 2>/dev/null)

    #create temporary cookie with guest account token
    echo '.gofile.io TRUE / TRUE 0 accountToken '"$token" > .cookies

    #get content info from api
    resp=$(curl 'https://api.gofile.io/getContent?contentId='"$id"'&token='"$token"'&websiteToken=12345&cache=true' 2>/dev/null)

    #load the page once so download links don't get redirected
    curl -L -b .cookies "$url" -o /dev/null 2>/dev/null
    curl -H 'Cookie: accountToken='"$token" "$1" -o /dev/null 2>/dev/null

    for i in $(jq '.data.contents | keys | .[]' <<< "$resp"); do
    name=$(jq -r '.data.contents['"$i"'].name' <<< "$resp")
    url=$(jq -r '.data.contents['"$i"'].link' <<< "$resp")
    echo
    echo "Downloading $name"
    curl -L -b .cookies $url -o "$name"
    curl -H 'Cookie: accountToken='"$token" "$url" -o "$name"
    done

    rm .cookies

    echo
    echo
    echo "Note: gofile.io is entirely free with no ads,"
    echo "you can support it at https://gofile.io/donate"
    echo "you can support it at https://gofile.io/donate"
  3. @shawnli87 shawnli87 revised this gist Aug 23, 2022. 1 changed file with 20 additions and 10 deletions.
    30 changes: 20 additions & 10 deletions download_gofile.sh
    Original file line number Diff line number Diff line change
    @@ -1,20 +1,30 @@
    #!/bin/bash

    id=`sed -E 's/.*gofile.io\/d\/(\w*?)/\1/' <<< $1`
    id=$(sed 's|.*gofile.io/d/||g' <<< "$1")
    echo "Downloading $id"

    server=`curl -s https://apiv2.gofile.io/getServer?c=$id | jq -r '.data.server'`
    files=`curl -s https://$server.gofile.io/getUpload?c=$id | jq '.data.files'`
    #get guest account token for url and cookie
    token=$(curl -s 'https://api.gofile.io/createAccount' | jq -r '.data.token' 2>/dev/null)

    for key in `jq 'keys | .[]' <<< $files`; do
    file=`jq ".[$key]" <<< $files`
    url=`jq -r '.link' <<< $file`
    name=`jq -r '.name' <<< $file`
    echo
    echo "Downloading $name"
    curl $url -o "$name"
    #create temporary cookie with guest account token
    echo '.gofile.io TRUE / TRUE 0 accountToken '"$token" > .cookies

    #get content info from api
    resp=$(curl 'https://api.gofile.io/getContent?contentId='"$id"'&token='"$token"'&websiteToken=12345&cache=true' 2>/dev/null)

    #load the page once so download links don't get redirected
    curl -L -b .cookies "$url" -o /dev/null 2>/dev/null

    for i in $(jq '.data.contents | keys | .[]' <<< "$resp"); do
    name=$(jq -r '.data.contents['"$i"'].name' <<< "$resp")
    url=$(jq -r '.data.contents['"$i"'].link' <<< "$resp")
    echo
    echo "Downloading $name"
    curl -L -b .cookies $url -o "$name"
    done

    rm .cookies

    echo
    echo
    echo "Note: gofile.io is entirely free with no ads,"
  4. @MCOfficer MCOfficer revised this gist Oct 14, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions download_gofile.sh
    Original file line number Diff line number Diff line change
    @@ -3,8 +3,8 @@
    id=`sed -E 's/.*gofile.io\/d\/(\w*?)/\1/' <<< $1`
    echo "Downloading $id"
    info=`curl -s https://srv-store5.gofile.io/getUpload?c=$id`
    files=`jq '.data.files' <<< $info`
    server=`curl -s https://apiv2.gofile.io/getServer?c=$id | jq -r '.data.server'`
    files=`curl -s https://$server.gofile.io/getUpload?c=$id | jq '.data.files'`
    for key in `jq 'keys | .[]' <<< $files`; do
    file=`jq ".[$key]" <<< $files`
  5. @MCOfficer MCOfficer revised this gist Oct 14, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion download_gofile.sh
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    id=`sed -E 's/.*gofile.io\/d\/(\w*?)/\1/' <<< $1`
    echo "Downloading $id"
    info=`curl -s https://srv-store5.gofile.io/getUpload?c=$id | jq -c`
    info=`curl -s https://srv-store5.gofile.io/getUpload?c=$id`
    files=`jq '.data.files' <<< $info`

    for key in `jq 'keys | .[]' <<< $files`; do
  6. @MCOfficer MCOfficer created this gist Oct 14, 2020.
    21 changes: 21 additions & 0 deletions download_gofile.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    #!/bin/bash

    id=`sed -E 's/.*gofile.io\/d\/(\w*?)/\1/' <<< $1`
    echo "Downloading $id"
    info=`curl -s https://srv-store5.gofile.io/getUpload?c=$id | jq -c`
    files=`jq '.data.files' <<< $info`

    for key in `jq 'keys | .[]' <<< $files`; do
    file=`jq ".[$key]" <<< $files`
    url=`jq -r '.link' <<< $file`
    name=`jq -r '.name' <<< $file`
    echo
    echo "Downloading $name"
    curl $url -o "$name"
    done

    echo
    echo
    echo "Note: gofile.io is entirely free with no ads,"
    echo "you can support it at https://gofile.io/donate"