Skip to content

Instantly share code, notes, and snippets.

@bkj
Created December 6, 2018 15:48
Show Gist options
  • Save bkj/986534373b2f041fa506ef5655027fcc to your computer and use it in GitHub Desktop.
Save bkj/986534373b2f041fa506ef5655027fcc to your computer and use it in GitHub Desktop.
script to download large file from google drive programatically
#!/bin/bash
# download_google_drive.sh
function download_google_drive {
SRC=$1
DST=$2
echo "$SRC -> $DST"
curl -c /tmp/cookies "https://drive.google.com/uc?export=download&id=$SRC" > /tmp/intermezzo.html
DL_LINK=$(cat /tmp/intermezzo.html |\
grep -Po 'uc-download-link" [^>]* href="\K[^"]*' |\
sed 's/\&/\&/g'
)
curl -L -b /tmp/cookies https://drive.google.com$DL_LINK > $DST
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment