Skip to content

Instantly share code, notes, and snippets.

@shawnli87
Forked from rexlManu/workupload_download.sh
Created August 27, 2022 04:47
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shawnli87/f226b4f0c7b2bef2e94477ccef00b0c8 to your computer and use it in GitHub Desktop.
Save shawnli87/f226b4f0c7b2bef2e94477ccef00b0c8 to your computer and use it in GitHub Desktop.
Download workupload files via curl
#!/bin/bash
[ -z "$1" ] && echo "Usage: workupload_download.sh '<workupload link>'" && exit 1
id_string=$(sed 's|.*workupload.com/||g' <<< "$1")
type=$(cut -d'/' -f1 <<< "$id_string")
id=$(cut -d'/' -f2 <<< "$id_string")
[[ "$type" != "file" ]] && [[ "$type" != "archive" ]] && echo "Invalid link provided" && exit 1
if [[ "$type" == "file" ]] ; then
start_url='https://workupload.com/start/'"$id"
elif [[ "$type" == "archive" ]] ; then
start_url='https://workupload.com/archive/'"$id"'/start'
fi
echo "Getting token from workupload servers"
token=$(curl -s -c - "$1" | tail -n1 | awk '{ print $7 }')
echo "Getting download url from workupload servers"
dl_url=$(curl -H 'Cookie: token='"$token" 'https://workupload.com/api/'"$type"'/getDownloadServer/'"$id" 2>/dev/null | jq -r '.data.url')
echo "Starting to download the actual file"
curl -H 'Cookie: token='"$token" "$dl_url" -s -O -J --compressed
echo "Download finished. Have a happy day :)"
@DarrenPIngram
Copy link

Thanks for going to this effort. I tried it just using the URL given first.

After a few minutes on my server it was sitting at

./workcloud-dl.sh https://workupload.com/archive/7V3z6mrq
Getting token from workupload servers
Getting download url from workupload servers
Starting to download the actual file

(The only change I made is what I called the script, to make it easier to remember with others).

I saw no errors. Anything I can check? Also would there be scope for a rudimentary healthcheck (x% or so much downloaded)?

@shawnli87
Copy link
Author

Thanks for going to this effort. I tried it just using the URL given first.

After a few minutes on my server it was sitting at

./workcloud-dl.sh https://workupload.com/archive/7V3z6mrq Getting token from workupload servers Getting download url from workupload servers Starting to download the actual file

(The only change I made is what I called the script, to make it easier to remember with others).

I saw no errors. Anything I can check? Also would there be scope for a rudimentary healthcheck (x% or so much downloaded)?

I tried to keep as much of the original script unchanged as possible, since I am not the original author. However, removing the '-s' flag from the curl command (on line 24) should yield in a progress bar, IIRC. Not near a computer at the moment to test.

@DarrenPIngram
Copy link

DarrenPIngram commented Sep 1, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment