Created
November 8, 2017 20:58
-
-
Save ppetraki/258ea8240041e19ab258a736781f06db to your computer and use it in GitHub Desktop.
allows you do non-interactively download large public files from gdrive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SOURCE="$1" | |
if [ "${SOURCE}" == "" ]; then | |
echo "Must specify a source url" | |
exit 1 | |
fi | |
DEST="$2" | |
if [ "${DEST}" == "" ]; then | |
echo "Must specify a destination filename" | |
exit 1 | |
fi | |
FILEID=$(echo $SOURCE | rev | cut -d= -f1 | rev) | |
COOKIES=$(mktemp) | |
CODE=$(wget --save-cookies $COOKIES --keep-session-cookies --no-check-certificate "https://docs.google.com/uc?export=download&id=${FILEID}" -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/Code: \1\n/p') | |
# cleanup the code, format is 'Code: XXXX' | |
CODE=$(echo $CODE | rev | cut -d: -f1 | rev | xargs) | |
wget --load-cookies $COOKIES "https://docs.google.com/uc?export=download&confirm=${CODE}&id=${FILEID}" -O $DEST | |
rm -f $COOKIES |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment