Skip to content

Instantly share code, notes, and snippets.

@afunTW
Created August 4, 2018 08:24
Show Gist options
  • Save afunTW/2b2dedc667e505d7f3a4915a451fcfc1 to your computer and use it in GitHub Desktop.
Save afunTW/2b2dedc667e505d7f3a4915a451fcfc1 to your computer and use it in GitHub Desktop.
download the big file on google drive which will pop-up the virus scanner warning
download_from_gdrive() {
file_id=$1
file_name=$2
# first stage to get the warning html
curl -c /tmp/cookies \
"https://drive.google.com/uc?export=download&id=$file_id" > \
/tmp/intermezzo.html
# second stage to extract the download link from html above
download_link=$(cat /tmp/intermezzo.html | \
grep -Po 'uc-download-link" [^>]* href="\K[^"]*' | \
sed 's/\&/\&/g')
curl -L -b /tmp/cookies \
"https://drive.google.com$download_link" > $file_name
}
# download_from_gdrive <FILE_ID> <OUTPUT_FILENAME>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment